



'''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 				lowerCamelCase__	(						_A    ):  # picklable for multiprocessing
  return i + 1
@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 				lowerCamelCase__	(						):
  with parallel_backend('spark'    ):
    assert ParallelBackendConfig.backend_name == "spark"

  a						: Dict					       =					[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 				lowerCamelCase__	(						_A    ):
  a						: Optional[int]					       =					[1, 2]
  a						: str					       =					{'a': 1, 'b': 2}
  a						: Dict					       =					{'a': [1, 2], 'b': [3, 4]}
  a						: Optional[Any]					       =					{'a': {'1': 1}, 'b': 2}
  a						: str					       =					{'a': 1, 'b': 2, 'c': 3, 'd': 4}
  a						: str					       =					[2, 3]
  a						: str					       =					{'a': 2, 'b': 3}
  a						: int					       =					{'a': [2, 3], 'b': [4, 5]}
  a						: List[Any]					       =					{'a': {'1': 2}, 'b': 3}
  a						: Tuple					       =					{'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




'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCAmelCase: List[Any]							=						{}

try:
     if not is_sentencepiece_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCAmelCase: Optional[int]							=						['NllbTokenizer']

try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCAmelCase: Dict							=						['NllbTokenizerFast']


if TYPE_CHECKING:
     try:
          if not is_sentencepiece_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_nllb import NllbTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_nllb_fast import NllbTokenizerFast

else:
     import sys

     lowerCAmelCase: Tuple							=						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)