Synthesis_incorporation/value_search/value_search.py [745:813]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    benchmark: benchmark_module.Benchmark,
    operations: List[operation_base.Operation],
    start_time: float,
    settings: settings_module.Settings,
    prediction_model: Optional[PredictionModel] = None,
    snippet_constant_multipliers: Optional[Dict[Text, float]] = None
) -> Tuple[
    List[Solution],
    Set[value_module.Value],
    ValuesByWeight,
    Optional[operation_statistics.OperationStatistics],
]:
    """Helper, returning (solutions, value_set, values_by_weight, statistics)."""
    timeout_reached = False
    end_time = start_time + settings.timeout

    only_minimal_solutions = settings.only_minimal_solutions
    if settings.max_solutions == 1:
        # If we only want one solution, it will be minimal.
        only_minimal_solutions = True

    # An object to track statistics, if requested.
    statistics = (
        operation_statistics.OperationStatistics()
        if settings.printing.statistics
        else None
    )

    # A list of Solution namedtuples.
    solutions = []

    # A set of string solution expressions (don't return duplicate solutions).
    solution_expression_set = set()

    # The output value to search for.
    output_value = value_module.OutputValue(benchmark.examples[0].output)

    # A list of OrderedDicts mapping Value objects to themselves. The i-th
    # OrderedDict contains all Value objects of weight i.
    values_by_weight = [
        collections.OrderedDict() for _ in range(settings.max_weight + 1)
    ]

    # Find and cache the constant and casting operations for use later.
    constant_operation = None
    int_operation = None
    float_operation = None
    bool_operation = None
    for operation in operations:
        if operation.name == torch_functions.CONSTANT_OPERATION_NAME:
            constant_operation = operation
        elif operation.name == torch_functions.INT_OPERATION_NAME:
            int_operation = operation
        elif operation.name == torch_functions.FLOAT_OPERATION_NAME:
            float_operation = operation
        elif operation.name == torch_functions.BOOL_OPERATION_NAME:
            bool_operation = operation
    # Create the output dtype value for use later.
    dtype_value = value_module.ConstantValue(output_value.dtype)

    # Populate values_by_weight with inputs and constants. This also prints
    # inputs/output/constants to stdout.
    _add_constants_and_inputs_and_print(
        values_by_weight, benchmark, output_value, constant_operation, settings, snippet_constant_multipliers
    )

    # A set storing all values found so far.
    value_set = set().union(*values_by_weight)
    constants_values = [value for value in value_set if not value.is_tensor]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



Synthesis_incorporation/value_search/value_search.py [910:978]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    benchmark: benchmark_module.Benchmark,
    operations: List[operation_base.Operation],
    start_time: float,
    settings: settings_module.Settings,
    prediction_model: Optional[PredictionModel] = None,
    snippet_constant_multipliers: Optional[Dict[Text, float]] = None
) -> Tuple[
    List[Solution],
    Set[value_module.Value],
    ValuesByWeight,
    Optional[operation_statistics.OperationStatistics],
]:
    """Helper, returning (solutions, value_set, values_by_weight, statistics)."""
    timeout_reached = False
    end_time = start_time + settings.timeout

    only_minimal_solutions = settings.only_minimal_solutions
    if settings.max_solutions == 1:
        # If we only want one solution, it will be minimal.
        only_minimal_solutions = True

    # An object to track statistics, if requested.
    statistics = (
        operation_statistics.OperationStatistics()
        if settings.printing.statistics
        else None
    )

    # A list of Solution namedtuples.
    solutions = []

    # A set of string solution expressions (don't return duplicate solutions).
    solution_expression_set = set()

    # The output value to search for.
    output_value = value_module.OutputValue(benchmark.examples[0].output)

    # A list of OrderedDicts mapping Value objects to themselves. The i-th
    # OrderedDict contains all Value objects of weight i.
    values_by_weight = [
        collections.OrderedDict() for _ in range(settings.max_weight + 1)
    ]

    # Find and cache the constant and casting operations for use later.
    constant_operation = None
    int_operation = None
    float_operation = None
    bool_operation = None
    for operation in operations:
        if operation.name == torch_functions.CONSTANT_OPERATION_NAME:
            constant_operation = operation
        elif operation.name == torch_functions.INT_OPERATION_NAME:
            int_operation = operation
        elif operation.name == torch_functions.FLOAT_OPERATION_NAME:
            float_operation = operation
        elif operation.name == torch_functions.BOOL_OPERATION_NAME:
            bool_operation = operation
    # Create the output dtype value for use later.
    dtype_value = value_module.ConstantValue(output_value.dtype)

    # Populate values_by_weight with inputs and constants. This also prints
    # inputs/output/constants to stdout.
    _add_constants_and_inputs_and_print(
        values_by_weight, benchmark, output_value, constant_operation, settings, snippet_constant_multipliers
    )

    # A set storing all values found so far.
    value_set = set().union(*values_by_weight)
    constants_values = [value for value in value_set if not value.is_tensor]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



