
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 a__    (       A_					):  # picklable for multiprocessing






  '''simple docstring'''





  return i + 1

@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def a__    (       ):






  '''simple docstring'''





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

  __magic_name__				     =       [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 a__    (       A_					):






  '''simple docstring'''





  __magic_name__				     =       [1, 2]
  __magic_name__				     =       {"""a""": 1, """b""": 2}
  __magic_name__				     =       {"""a""": [1, 2], """b""": [3, 4]}
  __magic_name__				     =       {"""a""": {"""1""": 1}, """b""": 2}
  __magic_name__				     =       {"""a""": 1, """b""": 2, """c""": 3, """d""": 4}
  __magic_name__				     =       [2, 3]
  __magic_name__				     =       {"""a""": 2, """b""": 3}
  __magic_name__				     =       {"""a""": [2, 3], """b""": [4, 5]}
  __magic_name__				     =       {"""a""": {"""1""": 2}, """b""": 3}
  __magic_name__				     =       {"""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 ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


__lowerCAmelCase			:     List[str]           =   {
    'configuration_xlm': ['XLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLMConfig', 'XLMOnnxConfig'],
    'tokenization_xlm': ['XLMTokenizer'],
}

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCAmelCase			:     str           =   [
        'XLM_PRETRAINED_MODEL_ARCHIVE_LIST',
        'XLMForMultipleChoice',
        'XLMForQuestionAnswering',
        'XLMForQuestionAnsweringSimple',
        'XLMForSequenceClassification',
        'XLMForTokenClassification',
        'XLMModel',
        'XLMPreTrainedModel',
        'XLMWithLMHeadModel',
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __lowerCAmelCase			:     Dict           =   [
        'TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST',
        'TFXLMForMultipleChoice',
        'TFXLMForQuestionAnsweringSimple',
        'TFXLMForSequenceClassification',
        'TFXLMForTokenClassification',
        'TFXLMMainLayer',
        'TFXLMModel',
        'TFXLMPreTrainedModel',
        'TFXLMWithLMHeadModel',
    ]


if TYPE_CHECKING:
    from .configuration_xlm import XLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMConfig, XLMOnnxConfig
    from .tokenization_xlm import XLMTokenizer

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_xlm import (
            XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
            XLMForMultipleChoice,
            XLMForQuestionAnswering,
            XLMForQuestionAnsweringSimple,
            XLMForSequenceClassification,
            XLMForTokenClassification,
            XLMModel,
            XLMPreTrainedModel,
            XLMWithLMHeadModel,
        )

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_xlm import (
            TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFXLMForMultipleChoice,
            TFXLMForQuestionAnsweringSimple,
            TFXLMForSequenceClassification,
            TFXLMForTokenClassification,
            TFXLMMainLayer,
            TFXLMModel,
            TFXLMPreTrainedModel,
            TFXLMWithLMHeadModel,
        )

else:
    import sys

    __lowerCAmelCase			:     Any           =   _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

