from __future__ import annotations

import gc
import inspect
import os
import time
from pathlib import Path
from unittest.mock import MagicMock, Mock, patch

import dill as pickle
import pytest
from inference.core.models.base import Model
from inference.models.qwen3vl.qwen3vl_inference_models import \
    InferenceModelsQwen3VLAdapter
from inference_models import PreProcessingOverrides
from inference_models.models.qwen3vl.qwen3vl_hf import Qwen3VLHF


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_map_inference_kwargs_empty_dict():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with empty input dictionary'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_empty_dict', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_all_false():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with all disable flags set to False'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': False, 'disable_preproc_grayscale': False, 'disable_preproc_static_crop': False}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_all_false', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_all_true():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with all disable flags set to True'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True, 'disable_preproc_grayscale': True, 'disable_preproc_static_crop': True}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_all_true', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_mixed_values():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with mixed True/False values'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True, 'disable_preproc_grayscale': False, 'disable_preproc_static_crop': True}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_mixed_values', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_preserves_other_keys():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that map_inference_kwargs preserves other kwargs keys'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True, 'other_param': 'value', 'another_param': 42}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_preserves_other_keys', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_returns_dict():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that map_inference_kwargs returns a dictionary'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind({})
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_returns_dict', 'map_inference_kwargs', '3', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_modifies_input():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that map_inference_kwargs modifies the input dictionary in place'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_modifies_input', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_partial_keys():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with only one disable key present'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_partial_keys', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_with_none_values():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs when disable keys have None values'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': None, 'disable_preproc_grayscale': None, 'disable_preproc_static_crop': None}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_with_none_values', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_extra_disable_keys():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with extra disable keys not part of the expected set'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True, 'disable_preproc_grayscale': False, 'disable_preproc_static_crop': True, 'disable_preproc_unknown': True, 'some_other_param': 'ignored'}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_extra_disable_keys', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_with_integer_values():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs when boolean values are provided as integers'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': 1, 'disable_preproc_grayscale': 0, 'disable_preproc_static_crop': 1}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_with_integer_values', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_with_string_values():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs when boolean values are provided as strings'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': 'true', 'disable_preproc_grayscale': 'false', 'disable_preproc_static_crop': 'True'}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_with_string_values', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_overrides_existing_preproc():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that map_inference_kwargs replaces existing pre_processing_overrides'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    old_overrides = PreProcessingOverrides(disable_contrast_enhancement=False, disable_grayscale=False, disable_static_crop=False)
    input_kwargs = {'pre_processing_overrides': old_overrides, 'disable_preproc_contrast': True}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_overrides_existing_preproc', 'map_inference_kwargs', '5', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_with_large_dict():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with a large dictionary containing many parameters'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True, 'disable_preproc_grayscale': False, 'disable_preproc_static_crop': True}
    for i in range(100):
        input_kwargs[f'param_{i}'] = f'value_{i}'
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_with_large_dict', 'map_inference_kwargs', '5', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output
    for i in range(100):
        pass

def test_map_inference_kwargs_with_nested_dict():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with nested dictionary values'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True, 'nested_config': {'sub_key': 'sub_value', 'numbers': [1, 2, 3]}}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_with_nested_dict', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_with_list_values():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with list values in the input'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True, 'class_list': ['person', 'car', 'dog'], 'numeric_list': [1, 2, 3, 4, 5]}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_with_list_values', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_preprocessing_overrides_type():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that the created pre_processing_overrides is of correct type'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind({})
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_preprocessing_overrides_type', 'map_inference_kwargs', '3', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_with_many_parameters():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with 1000 additional parameters'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True, 'disable_preproc_grayscale': False, 'disable_preproc_static_crop': True}
    for i in range(1000):
        input_kwargs[f'param_{i}'] = f'value_{i}'
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_with_many_parameters', 'map_inference_kwargs', '5', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_multiple_calls_consistency():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test that multiple calls to map_inference_kwargs produce consistent results'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs_template = {'disable_preproc_contrast': True, 'disable_preproc_grayscale': False, 'disable_preproc_static_crop': True}
    results = []
    for _ in range(100):
        input_kwargs = input_kwargs_template.copy()
        _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
        _call__bound__arguments.apply_defaults()
        codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_multiple_calls_consistency', 'map_inference_kwargs', '5_1', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
        codeflash_output = codeflash_return_value
        result = codeflash_output
        results.append(result)
    for i, result in enumerate(results):
        pass

def test_map_inference_kwargs_with_complex_nested_structures():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with complex nested structures and 500 elements'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True, 'config': {'nested': {'deep': {'values': [i for i in range(100)]}}}, 'array_of_dicts': [{'id': i, 'name': f'item_{i}', 'nested': {'value': i * 2}} for i in range(500)]}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_with_complex_nested_structures', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output

def test_map_inference_kwargs_with_special_characters_in_keys():
    codeflash_loop_index = int(os.environ['CODEFLASH_LOOP_INDEX'])
    'Test map_inference_kwargs with special characters in parameter keys'
    adapter = Mock(spec=InferenceModelsQwen3VLAdapter)
    adapter.map_inference_kwargs = InferenceModelsQwen3VLAdapter.map_inference_kwargs.__get__(adapter)
    input_kwargs = {'disable_preproc_contrast': True, 'param-with-dash': 'value1', 'param.with.dot': 'value2', 'param_with_underscore': 'value3', 'param123': 'value4'}
    _call__bound__arguments = inspect.signature(adapter.map_inference_kwargs).bind(input_kwargs)
    _call__bound__arguments.apply_defaults()
    codeflash_return_value = codeflash_wrap(adapter.map_inference_kwargs, 'tests.inference.unit_tests.test_map_inference_kwargs__unit_test_1', None, 'test_map_inference_kwargs_with_special_characters_in_keys', 'map_inference_kwargs', '4', codeflash_loop_index, *_call__bound__arguments.args, **_call__bound__arguments.kwargs)
    codeflash_output = codeflash_return_value
    result = codeflash_output