




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_   (UpperCamelCase	:  int				):  # 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"

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

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

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





							'''simple docstring'''


							_a     					=    [1, 2]
							_a     					=    {'''a''': 1, '''b''': 2}
							_a     					=    {'''a''': [1, 2], '''b''': [3, 4]}
							_a     					=    {'''a''': {'''1''': 1}, '''b''': 2}
							_a     					=    {'''a''': 1, '''b''': 2, '''c''': 3, '''d''': 4}
							_a     					=    [2, 3]
							_a     					=    {'''a''': 2, '''b''': 3}
							_a     					=    {'''a''': [2, 3], '''b''': [4, 5]}
							_a     					=    {'''a''': {'''1''': 2}, '''b''': 3}
							_a     					=    {'''a''': 2, '''b''': 3, '''c''': 4, '''d''': 5}

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







'''simple docstring'''


from ..utils import DummyObject, requires_backends

class       A   (		metaclass=_a   ):
							lowercase_          =    ['torch', 'scipy']







							def __init__(  self	:  Tuple							,      *lowerCAmelCase_	:  str							,      **lowerCAmelCase_	:  Any )      ->							Tuple:


														"""simple docstring"""


														requires_backends(self							,      ['''torch''', '''scipy'''] )







							@classmethod
							def        __lowerCAmelCase      (  cls	:  Dict							,      *lowerCAmelCase_	:  Dict							,      **lowerCAmelCase_	:  str )      ->							Tuple:


														"""simple docstring"""


														requires_backends(cls							,      ['''torch''', '''scipy'''] )







							@classmethod
							def        __lowerCAmelCase      (  cls	:  Optional[int]							,      *lowerCAmelCase_	:  str							,      **lowerCAmelCase_	:  List[str] )      ->							str:


														"""simple docstring"""


														requires_backends(cls							,      ['''torch''', '''scipy'''] )

