




'''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 		__magic_name__    (	__UpperCAmelCase	)		->					List[Any]:  # picklable for multiprocessing

					'''simple docstring'''

					return i + 1


@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 		__magic_name__    (	)		->					List[str]:

					'''simple docstring'''

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

					snake_case_									=				[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 		__magic_name__    (	__UpperCAmelCase	)		->					Optional[Any]:

					'''simple docstring'''

					snake_case_									=				[1, 2]
					snake_case_									=				{'''a''': 1, '''b''': 2}
					snake_case_									=				{'''a''': [1, 2], '''b''': [3, 4]}
					snake_case_									=				{'''a''': {'''1''': 1}, '''b''': 2}
					snake_case_									=				{'''a''': 1, '''b''': 2, '''c''': 3, '''d''': 4}
					snake_case_									=				[2, 3]
					snake_case_									=				{'''a''': 2, '''b''': 3}
					snake_case_									=				{'''a''': [2, 3], '''b''': [4, 5]}
					snake_case_									=				{'''a''': {'''1''': 2}, '''b''': 3}
					snake_case_									=				{'''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








import os
from distutils.util import strtobool



def    __lowercase   (      _SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE	) ->   Tuple:


      '''simple docstring'''


      for e in env_keys:
            SCREAMING_SNAKE_CASE		=						int(os.environ.get(_SCREAMING_SNAKE_CASE ,						-1	)	)
            if val >= 0:
                  return val
      return default



def    __lowercase   (      _SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE=False	) ->   Optional[int]:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE		=						os.environ.get(_SCREAMING_SNAKE_CASE ,						str(_SCREAMING_SNAKE_CASE	)	)
      return strtobool(_SCREAMING_SNAKE_CASE	) == 1  # As its name indicates `strtobool` actually returns an int...



def    __lowercase   (      _SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE="no"	) ->   Any:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE		=						os.environ.get(_SCREAMING_SNAKE_CASE ,						str(_SCREAMING_SNAKE_CASE	)	)
      return value


