



"""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 	_SCREAMING_SNAKE_CASE  (__lowerCAmelCase							)       ->  int:  # picklable for multiprocessing







  '''simple docstring'''


  return i + 1


@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 	_SCREAMING_SNAKE_CASE  ()       ->  Any:







  '''simple docstring'''


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

  lowercase_	    =       [1, 2, 3]
  with pytest.raises(__snake_case							):
    with parallel_backend("""unsupported backend"""							):
      map_nested(__snake_case       ,     __snake_case       ,     num_proc=2							)

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


@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize("""num_proc"""       ,     [2, -1]							)
def 	_SCREAMING_SNAKE_CASE  (__lowerCAmelCase							)       ->  Tuple:







  '''simple docstring'''


  lowercase_	    =       [1, 2]
  lowercase_	    =       {"""a""": 1, """b""": 2}
  lowercase_	    =       {"""a""": [1, 2], """b""": [3, 4]}
  lowercase_	    =       {"""a""": {"""1""": 1}, """b""": 2}
  lowercase_	    =       {"""a""": 1, """b""": 2, """c""": 3, """d""": 4}
  lowercase_	    =       [2, 3]
  lowercase_	    =       {"""a""": 2, """b""": 3}
  lowercase_	    =       {"""a""": [2, 3], """b""": [4, 5]}
  lowercase_	    =       {"""a""": {"""1""": 2}, """b""": 3}
  lowercase_	    =       {"""a""": 2, """b""": 3, """c""": 4, """d""": 5}

  with parallel_backend("""spark"""							):
    assert map_nested(__snake_case       ,     __snake_case       ,     num_proc=__snake_case							) == expected_map_nested_sa
    assert map_nested(__snake_case       ,     __snake_case       ,     num_proc=__snake_case							) == expected_map_nested_sa
    assert map_nested(__snake_case       ,     __snake_case       ,     num_proc=__snake_case							) == expected_map_nested_sa
    assert map_nested(__snake_case       ,     __snake_case       ,     num_proc=__snake_case							) == expected_map_nested_sa
    assert map_nested(__snake_case       ,     __snake_case       ,     num_proc=__snake_case							) == expected_map_nested_sa








from typing import TYPE_CHECKING

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


_a 						=      {
    "configuration_lxmert": ["LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "LxmertConfig"],
    "tokenization_lxmert": ["LxmertTokenizer"],
}

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

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_a 						=      [
			    "LxmertEncoder",
			    "LxmertForPreTraining",
			    "LxmertForQuestionAnswering",
			    "LxmertModel",
			    "LxmertPreTrainedModel",
			    "LxmertVisualFeatureEncoder",
			    "LxmertXLayer",
			]

try:
			if not is_tf_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_a 						=      [
			    "TF_LXMERT_PRETRAINED_MODEL_ARCHIVE_LIST",
			    "TFLxmertForPreTraining",
			    "TFLxmertMainLayer",
			    "TFLxmertModel",
			    "TFLxmertPreTrainedModel",
			    "TFLxmertVisualFeatureEncoder",
			]


if TYPE_CHECKING:
			from .configuration_lxmert import LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP, LxmertConfig
			from .tokenization_lxmert import LxmertTokenizer

			try:
						if not is_tokenizers_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .tokenization_lxmert_fast import LxmertTokenizerFast

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_lxmert import (
						    LxmertEncoder,
						    LxmertForPreTraining,
						    LxmertForQuestionAnswering,
						    LxmertModel,
						    LxmertPreTrainedModel,
						    LxmertVisualFeatureEncoder,
						    LxmertXLayer,
						)

			try:
						if not is_tf_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_tf_lxmert import (
						    TF_LXMERT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    TFLxmertForPreTraining,
						    TFLxmertMainLayer,
						    TFLxmertModel,
						    TFLxmertPreTrainedModel,
						    TFLxmertVisualFeatureEncoder,
						)

else:
			import sys

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



