from __future__ import annotations

import gc
import inspect
import os
import time
from pathlib import Path
from typing import List

import dill as pickle
import pytest
from inference.core.workflows.core_steps.common.query_language.entities.introspection import \
    OperatorDescription
from inference.core.workflows.core_steps.common.query_language.entities.operations import (
    DoesNotExist, Equals, Exists, In, IsEmpty, IsFalse, IsNotEmpty, IsTrue,
    NotEquals, NumberGreater, NumberGreaterEqual, NumberLower,
    NumberLowerEqual, StringContains, StringEndsWith, StringStartsWith)
from inference.core.workflows.core_steps.common.query_language.introspection.core import \
    prepare_operators_descriptions


def codeflash_wrap(codeflash_wrapped, codeflash_test_module_name, codeflash_test_class_name, codeflash_test_name, codeflash_function_name, codeflash_line_id, codeflash_loop_index, *args, **kwargs):
    test_id = f'{codeflash_test_module_name}:{codeflash_test_class_name}:{codeflash_test_name}:{codeflash_line_id}:{codeflash_loop_index}'
    if not hasattr(codeflash_wrap, 'index'):
        codeflash_wrap.index = {}
    if test_id in codeflash_wrap.index:
        codeflash_wrap.index[test_id] += 1
    else:
        codeflash_wrap.index[test_id] = 0
    codeflash_test_index = codeflash_wrap.index[test_id]
    invocation_id = f'{codeflash_line_id}_{codeflash_test_index}'
    test_stdout_tag = f"{codeflash_test_module_name}:{(codeflash_test_class_name + '.' if codeflash_test_class_name else '')}{codeflash_test_name}:{codeflash_function_name}:{codeflash_loop_index}:{invocation_id}"
    print(f'!$######{test_stdout_tag}######$!')
    exception = None
    gc.disable()
    try:
        counter = time.perf_counter_ns()
        return_value = codeflash_wrapped(*args, **kwargs)
        codeflash_duration = time.perf_counter_ns() - counter
    except Exception as e:
        codeflash_duration = time.perf_counter_ns() - counter
        exception = e
    gc.enable()
    print(f'!######{test_stdout_tag}######!')
    iteration = os.environ['CODEFLASH_TEST_ITERATION']
    with Path('{codeflash_run_tmp_dir_client_side}', f'test_return_values_{iteration}.bin').open('ab') as f:
        pickled_values = pickle.dumps((args, kwargs, exception)) if exception else pickle.dumps((args, kwargs, return_value))
        _test_name = f"{codeflash_test_module_name}:{(codeflash_test_class_name + '.' if codeflash_test_class_name else '')}{codeflash_test_name}:{codeflash_function_name}:{codeflash_line_id}".encode('ascii')
        f.write(len(_test_name).to_bytes(4, byteorder='big'))
        f.write(_test_name)
        f.write(codeflash_duration.to_bytes(8, byteorder='big'))
        f.write(len(pickled_values).to_bytes(4, byteorder='big'))
        f.write(pickled_values)
        f.write(codeflash_loop_index.to_bytes(8, byteorder='big'))
        f.write(len(invocation_id).to_bytes(4, byteorder='big'))
        f.write(invocation_id.encode('ascii'))
    if exception:
        raise exception
    return return_value

def test_returns_list():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that the function returns a list.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_returns_list', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_returns_list_of_operator_descriptions():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that all elements in the returned list are OperatorDescription instances.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_returns_list_of_operator_descriptions', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for item in result:
        pass

def test_result_not_empty():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that the result list contains at least one operator.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_result_not_empty', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_all_descriptions_have_operator_type():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that all operator descriptions have an operator_type field.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_all_descriptions_have_operator_type', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        pass

def test_all_descriptions_have_operands_number():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that all operator descriptions have an operands_number field.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_all_descriptions_have_operands_number', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        pass

def test_all_descriptions_have_operands_kinds():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that all operator descriptions have operands_kinds field.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_all_descriptions_have_operands_kinds', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        pass

def test_operands_number_matches_operands_kinds_length():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that operands_number matches the length of operands_kinds.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_operands_number_matches_operands_kinds_length', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        pass

def test_contains_in_operator():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    "Test that 'in (Sequence)' operator is present."
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_contains_in_operator', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    operator_types = [desc.operator_type for desc in result]

def test_contains_equals_operator():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    "Test that '==' or '(Number) ==' operator is present."
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_contains_equals_operator', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    operator_types = [desc.operator_type for desc in result]

def test_contains_exists_operator():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    "Test that 'Exists' operator is present."
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_contains_exists_operator', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    operator_types = [desc.operator_type for desc in result]

def test_contains_does_not_exist_operator():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    "Test that 'DoesNotExist' operator is present."
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_contains_does_not_exist_operator', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    operator_types = [desc.operator_type for desc in result]

def test_unary_operators_have_one_operand():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that unary operators have exactly one operand.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_unary_operators_have_one_operand', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    unary_operator_types = ['Exists', 'DoesNotExist', '(Boolean) is True', '(Boolean) is False', '(Sequence) is empty', '(Sequence) is not empty']
    for desc in result:
        if desc.operator_type in unary_operator_types:
            pass

def test_binary_operators_have_two_operands():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that binary operators have exactly two operands.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_binary_operators_have_two_operands', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    binary_operator_types = ['in (Sequence)', '==', '(Number) ==', '!=', '(Number) !=', '(Number) >', '(Number) >=', '(Number) <', '(Number) <=', '(String) contains', '(String) endsWith', '(String) startsWith']
    for desc in result:
        if desc.operator_type in binary_operator_types:
            pass

def test_description_field_is_optional():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that the description field is present and can be None or string.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_description_field_is_optional', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        pass

def test_all_operator_types_are_strings():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that all operator_type values are non-empty strings.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_all_operator_types_are_strings', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        pass

def test_operands_kinds_contains_lists():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that operands_kinds contains lists (kinds for each operand).'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_operands_kinds_contains_lists', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        for operand_kinds in desc.operands_kinds:
            pass

def test_no_duplicate_operator_types():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that there are no duplicate operator_type values in the result.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_no_duplicate_operator_types', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    operator_types = [desc.operator_type for desc in result]
    unique_types = set(operator_types)

def test_all_operators_from_specified_list():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that the result contains operators from the predefined list.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_all_operators_from_specified_list', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    operator_types = set((desc.operator_type for desc in result))

def test_operands_kinds_non_empty():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that operands_kinds are never empty for any operand.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_operands_kinds_non_empty', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        for operand_kinds in desc.operands_kinds:
            pass

def test_operands_number_positive():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that operands_number is always positive.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_operands_number_positive', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        pass

def test_string_operators_have_string_kinds():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that string operators specify STRING_KIND in operands_kinds.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_string_operators_have_string_kinds', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    string_operator_types = ['(String) contains', '(String) endsWith', '(String) startsWith']
    for desc in result:
        if desc.operator_type in string_operator_types:
            pass

def test_number_operators_present():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that number operators are included in the results.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_number_operators_present', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    operator_types = [desc.operator_type for desc in result]
    number_operators = ['(Number) >', '(Number) >=', '(Number) <', '(Number) <=']
    for op in number_operators:
        pass

def test_boolean_operators_present():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that boolean operators are included in the results.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_boolean_operators_present', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    operator_types = [desc.operator_type for desc in result]
    boolean_operators = ['(Boolean) is True', '(Boolean) is False']
    for op in boolean_operators:
        pass

def test_sequence_operators_present():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that sequence operators are included in the results.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_sequence_operators_present', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    operator_types = [desc.operator_type for desc in result]
    sequence_operators = ['(Sequence) is empty', '(Sequence) is not empty']
    for op in sequence_operators:
        pass

def test_result_contains_expected_operator_count():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that result contains a reasonable number of operators.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_result_contains_expected_operator_count', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_consistency_across_multiple_calls():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that multiple calls return consistent results.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_consistency_across_multiple_calls', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result1 = codeflash_output
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_consistency_across_multiple_calls', 'prepare_operators_descriptions', '3', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result2 = codeflash_output
    types1 = sorted([desc.operator_type for desc in result1])
    types2 = sorted([desc.operator_type for desc in result2])

def test_all_descriptions_are_valid_pydantic_models():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that all descriptions are valid pydantic OperatorDescription models.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_all_descriptions_are_valid_pydantic_models', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        model_data = desc.model_dump()

def test_operands_kinds_structure():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that operands_kinds has correct structure for all operators.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_operands_kinds_structure', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        for kinds_list in desc.operands_kinds:
            pass

def test_equals_has_multiple_aliases():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that Equals operator has multiple type aliases.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_equals_has_multiple_aliases', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    equals_operators = [desc for desc in result if '==' in desc.operator_type]
    operands_numbers = set((desc.operands_number for desc in equals_operators))

def test_not_equals_has_multiple_aliases():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that NotEquals operator has multiple type aliases.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_not_equals_has_multiple_aliases', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    not_equals_operators = [desc for desc in result if '!=' in desc.operator_type]
    operands_numbers = set((desc.operands_number for desc in not_equals_operators))

def test_all_operators_have_non_none_operands_kinds():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that all operators have non-None operands_kinds.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_all_operators_have_non_none_operands_kinds', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        pass

def test_deterministic_output():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that the function produces deterministic output.'
    results = []
    for _ in range(5):
        _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
        _call__bound__arguments.apply_defaults()
        codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_deterministic_output', 'prepare_operators_descriptions', '2_0', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
        codeflash_output = codeflash_return_value
        result = codeflash_output
        operator_descriptions = [(d.operator_type, d.operands_number) for d in result]
        results.append(sorted(operator_descriptions))
    first_result = results[0]
    for other_result in results[1:]:
        pass

def test_all_operators_have_schema_defined():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that all operators have proper schema information.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_all_operators_have_schema_defined', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for desc in result:
        pass

def test_large_iteration_performance():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that the function handles large-scale iteration efficiently.'
    _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_large_iteration_performance', 'prepare_operators_descriptions', '1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for _ in range(1000):
        for desc in result:
            _ = desc.operator_type
            _ = desc.operands_number

def test_result_list_length_consistency():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that result list length remains consistent.'
    lengths = []
    for _ in range(10):
        _call__bound__arguments = inspect.signature(prepare_operators_descriptions).bind()
        _call__bound__arguments.apply_defaults()
        codeflash_return_value = codeflash_wrap(prepare_operators_descriptions, 'tests.inference.unit_tests.test_prepare_operators_descriptions__unit_test_1', None, 'test_result_list_length_consistency', 'prepare_operators_descriptions', '2_0', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
        codeflash_output = codeflash_return_value
        result = codeflash_output
        lengths.append(len(result))
    unique_lengths = set(lengths)