




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







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

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

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







@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize('num_proc'							,    [2, -1]		)
def      _snake_case			(				lowercase__		):
				_lowerCamelCase     :			Optional[Any]    =    [1, 2]
				_lowerCamelCase     :			Any    =    {'a': 1, 'b': 2}
				_lowerCamelCase     :			int    =    {'a': [1, 2], 'b': [3, 4]}
				_lowerCamelCase     :			List[Any]    =    {'a': {'1': 1}, 'b': 2}
				_lowerCamelCase     :			List[Any]    =    {'a': 1, 'b': 2, 'c': 3, 'd': 4}
				_lowerCamelCase     :			Any    =    [2, 3]
				_lowerCamelCase     :			str    =    {'a': 2, 'b': 3}
				_lowerCamelCase     :			Dict    =    {'a': [2, 3], 'b': [4, 5]}
				_lowerCamelCase     :			List[str]    =    {'a': {'1': 2}, 'b': 3}
				_lowerCamelCase     :			Optional[Any]    =    {'a': 2, 'b': 3, 'c': 4, 'd': 5}

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





"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase__     						=						{"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]}

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowercase__     						=						[
			    """IBERT_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """IBertForMaskedLM""",
			    """IBertForMultipleChoice""",
			    """IBertForQuestionAnswering""",
			    """IBertForSequenceClassification""",
			    """IBertForTokenClassification""",
			    """IBertModel""",
			    """IBertPreTrainedModel""",
			]

if TYPE_CHECKING:
			from .configuration_ibert import IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, IBertConfig, IBertOnnxConfig

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_ibert import (
						    IBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    IBertForMaskedLM,
						    IBertForMultipleChoice,
						    IBertForQuestionAnswering,
						    IBertForSequenceClassification,
						    IBertForTokenClassification,
						    IBertModel,
						    IBertPreTrainedModel,
						)

else:
			import sys

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