



from ...processing_utils import ProcessorMixin

class        UpperCAmelCase_  (       UpperCamelCase_	):

						'''simple docstring'''




						UpperCamelCase__      :			Optional[Any]      =  ['''image_processor''', '''feature_extractor''']
						UpperCamelCase__      :			int      =  '''TvltImageProcessor'''
						UpperCamelCase__      :			Dict      =  '''TvltFeatureExtractor'''






						def __init__(   self				,							_A				,							_A		):







													'''simple docstring'''

													super().__init__(image_processor=_A				,							feature_extractor=_A		)

													__SCREAMING_SNAKE_CASE									= image_processor
													__SCREAMING_SNAKE_CASE									= feature_extractor






						def __call__(   self				,							_A=None				,							_A=None				,							_A=None				,							_A=None				,							_A=False				,							_A=False				,							*_A				,							**_A				,							):







													'''simple docstring'''

													if images is None and audio is None:
																				raise ValueError('You need to specify either an `images` or `audio` input to process.'		)

													__SCREAMING_SNAKE_CASE									= None
													if images is not None:
																				__SCREAMING_SNAKE_CASE									= self.image_processor(_A				,							mask_pixel=_A				,							*_A				,							**_A		)
													if images_mixed is not None:
																				__SCREAMING_SNAKE_CASE									= self.image_processor(_A				,							is_mixed=_A				,							*_A				,							**_A		)
													if audio is not None:
																				__SCREAMING_SNAKE_CASE									= self.feature_extractor(
																				    _A				,							*_A				,							sampling_rate=_A				,							mask_audio=_A				,							**_A		)

													__SCREAMING_SNAKE_CASE									= {}
													if audio is not None:
																				output_dict.update(_A		)
													if images is not None:
																				output_dict.update(_A		)
													if images_mixed_dict is not None:
																				output_dict.update(_A		)
													return output_dict






						@property
						def 	_A     (   self		):







													'''simple docstring'''

													__SCREAMING_SNAKE_CASE									= self.image_processor.model_input_names
													__SCREAMING_SNAKE_CASE									= self.feature_extractor.model_input_names
													return list(dict.fromkeys(image_processor_input_names + feature_extractor_input_names		)		)











import pytest

from datasets.parallel import ParallelBackendConfig, parallel_backend
from datasets.utils.py_utils import map_nested

from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows






def      __lowercase       (			a__       )    ->			List[Any]:  # picklable for multiprocessing
							return i + 1






@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def      __lowercase       (			)    ->			Any:
							with parallel_backend('spark'       ):
														assert ParallelBackendConfig.backend_name == "spark"

							__SCREAMING_SNAKE_CASE									= [1, 2, 3]
							with pytest.raises(a__       ):
														with parallel_backend('unsupported backend'       ):
																					map_nested(a__							,       a__							,       num_proc=2       )

							with pytest.raises(a__       ):
														with parallel_backend('unsupported backend'       ):
																					map_nested(a__							,       a__							,       num_proc=-1       )






@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize('num_proc'							,       [2, -1]       )
def      __lowercase       (			a__       )    ->			Union[str, Any]:
							__SCREAMING_SNAKE_CASE									= [1, 2]
							__SCREAMING_SNAKE_CASE									= {'a': 1, 'b': 2}
							__SCREAMING_SNAKE_CASE									= {'a': [1, 2], 'b': [3, 4]}
							__SCREAMING_SNAKE_CASE									= {'a': {'1': 1}, 'b': 2}
							__SCREAMING_SNAKE_CASE									= {'a': 1, 'b': 2, 'c': 3, 'd': 4}
							__SCREAMING_SNAKE_CASE									= [2, 3]
							__SCREAMING_SNAKE_CASE									= {'a': 2, 'b': 3}
							__SCREAMING_SNAKE_CASE									= {'a': [2, 3], 'b': [4, 5]}
							__SCREAMING_SNAKE_CASE									= {'a': {'1': 2}, 'b': 3}
							__SCREAMING_SNAKE_CASE									= {'a': 2, 'b': 3, 'c': 4, 'd': 5}

							with parallel_backend('spark'       ):
														assert map_nested(a__							,       a__							,       num_proc=a__       ) == expected_map_nested_sa
														assert map_nested(a__							,       a__							,       num_proc=a__       ) == expected_map_nested_sa
														assert map_nested(a__							,       a__							,       num_proc=a__       ) == expected_map_nested_sa
														assert map_nested(a__							,       a__							,       num_proc=a__       ) == expected_map_nested_sa
														assert map_nested(a__							,       a__							,       num_proc=a__       ) == expected_map_nested_sa






