
'''simple docstring'''







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  snake_case_		(    __SCREAMING_SNAKE_CASE :			List[str]							):  # picklable for multiprocessing



						"""simple docstring"""





						return i + 1
@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def  snake_case_		(    ):



						"""simple docstring"""





						with parallel_backend('''spark'''							):
												assert ParallelBackendConfig.backend_name == "spark"

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

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




@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize('''num_proc'''				,				[2, -1]							)
def  snake_case_		(    __SCREAMING_SNAKE_CASE :			Dict							):



						"""simple docstring"""





						lowercase_     :					List[str]													=	[1, 2]
						lowercase_     :					Any													=	{'''a''': 1, '''b''': 2}
						lowercase_     :					Dict													=	{'''a''': [1, 2], '''b''': [3, 4]}
						lowercase_     :					Any													=	{'''a''': {'''1''': 1}, '''b''': 2}
						lowercase_     :					List[str]													=	{'''a''': 1, '''b''': 2, '''c''': 3, '''d''': 4}
						lowercase_     :					int													=	[2, 3]
						lowercase_     :					Optional[int]													=	{'''a''': 2, '''b''': 3}
						lowercase_     :					Optional[Any]													=	{'''a''': [2, 3], '''b''': [4, 5]}
						lowercase_     :					Union[str, Any]													=	{'''a''': {'''1''': 2}, '''b''': 3}
						lowercase_     :					Optional[Any]													=	{'''a''': 2, '''b''': 3, '''c''': 4, '''d''': 5}

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





'''simple docstring'''







import logging
from dataclasses import dataclass, field
from pathlib import Path
from typing import Optional, Union

from .generation.configuration_utils import GenerationConfig
from .training_args import TrainingArguments
from .utils import add_start_docstrings


_lowercase			:  Tuple   							=	logging.getLogger(__name__)






@dataclass
@add_start_docstrings(TrainingArguments.__doc__					)
class 			lowerCAmelCase__       (  lowerCamelCase_					):
					lowerCAmelCase_					       =					field(default=lowerCamelCase_   ,						metadata={'''help''': '''Whether to use SortishSampler or not.'''}					)
					lowerCAmelCase_					       =					field(
					    default=lowerCamelCase_   ,						metadata={'''help''': '''Whether to use generate to calculate generative metrics (ROUGE, BLEU).'''}					)
					lowerCAmelCase_					       =					field(
					    default=lowerCamelCase_   ,						metadata={
					        '''help''': (
					            '''The `max_length` to use on each evaluation loop when `predict_with_generate=True`. Will default '''
					            '''to the `max_length` value of the model configuration.'''
					        )
					    }   ,						)
					lowerCAmelCase_					       =					field(
					    default=lowerCamelCase_   ,						metadata={
					        '''help''': (
					            '''The `num_beams` to use on each evaluation loop when `predict_with_generate=True`. Will default '''
					            '''to the `num_beams` value of the model configuration.'''
					        )
					    }   ,						)
					lowerCAmelCase_					       =					field(
					    default=lowerCamelCase_   ,						metadata={
					        '''help''': '''Model id, file path or url pointing to a GenerationConfig json file, to use during prediction.'''
					    }   ,						)






					def      _snake_case   (       self		):


											"""simple docstring"""





											lowercase_     :					Dict													=	super().to_dict()
											for k, v in d.items():
																	if isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		):
																							lowercase_     :					str													=	v.to_dict()
											return d



