






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 						__UpperCAmelCase			(     a_):  # picklable for multiprocessing
							return i + 1





@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 						__UpperCAmelCase			(     ):
							with parallel_backend('spark'):
														assert ParallelBackendConfig.backend_name == "spark"

							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 						__UpperCAmelCase			(     a_):
							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(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













from typing import TYPE_CHECKING

from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available
from ...utils import OptionalDependencyNotAvailable


lowercase  							=					{"configuration_gpt_neox": ["GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXConfig"]}

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	lowercase  							=					["GPTNeoXTokenizerFast"]

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	lowercase  							=					[
	    "GPT_NEOX_PRETRAINED_MODEL_ARCHIVE_LIST",
	    "GPTNeoXForCausalLM",
	    "GPTNeoXForQuestionAnswering",
	    "GPTNeoXForSequenceClassification",
	    "GPTNeoXForTokenClassification",
	    "GPTNeoXLayer",
	    "GPTNeoXModel",
	    "GPTNeoXPreTrainedModel",
	]


if TYPE_CHECKING:
	from .configuration_gpt_neox import GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTNeoXConfig

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_gpt_neox_fast import GPTNeoXTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_gpt_neox import (
		    GPT_NEOX_PRETRAINED_MODEL_ARCHIVE_LIST,
		    GPTNeoXForCausalLM,
		    GPTNeoXForQuestionAnswering,
		    GPTNeoXForSequenceClassification,
		    GPTNeoXForTokenClassification,
		    GPTNeoXLayer,
		    GPTNeoXModel,
		    GPTNeoXPreTrainedModel,
		)


else:
	import sys

	lowercase  							=					_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





