
'''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'''







from typing import Optional
from urllib.parse import quote

import huggingface_hub as hfh
from packaging import version
def  snake_case_		(    __SCREAMING_SNAKE_CASE :			str				,				__SCREAMING_SNAKE_CASE :			str				,				__SCREAMING_SNAKE_CASE :			Optional[str] = None							):



						"""simple docstring"""





						if version.parse(hfh.__version__							).release < version.parse('''0.11.0'''							).release:
												# old versions of hfh don't url-encode the file path
												lowercase_     :					int													=	quote(__SCREAMING_SNAKE_CASE							)
						return hfh.hf_hub_url(__SCREAMING_SNAKE_CASE				,				__SCREAMING_SNAKE_CASE				,				repo_type='''dataset'''				,				revision=__SCREAMING_SNAKE_CASE							)



