


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   (			__lowerCamelCase		: Dict				)      ->     Tuple:  # picklable for multiprocessing







     '''simple docstring'''






     return i + 1






@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def __UpperCamelCase   (			)      ->     str:







     '''simple docstring'''






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

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

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






@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize("num_proc"      ,  [2, -1]				)
def __UpperCamelCase   (			__lowerCamelCase		: Dict				)      ->     int:







     '''simple docstring'''






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

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





'''simple docstring'''

from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


lowercase__				     =		logging.get_logger(__name__)

lowercase__				     =		{
    "YituTech/conv-bert-base": "https://huggingface.co/YituTech/conv-bert-base/resolve/main/config.json",
    "YituTech/conv-bert-medium-small": (
        "https://huggingface.co/YituTech/conv-bert-medium-small/resolve/main/config.json"
    ),
    "YituTech/conv-bert-small": "https://huggingface.co/YituTech/conv-bert-small/resolve/main/config.json",
    # See all ConvBERT models at https://huggingface.co/models?filter=convbert
}





class 						__SCREAMING_SNAKE_CASE					(      lowerCamelCase__ ):
     UpperCAmelCase 					=				'''convbert'''






     def __init__(			self     ,							__UpperCamelCase=30_522     ,							__UpperCamelCase=768     ,							__UpperCamelCase=12     ,							__UpperCamelCase=12     ,							__UpperCamelCase=3_072     ,							__UpperCamelCase="gelu"     ,							__UpperCamelCase=0.1     ,							__UpperCamelCase=0.1     ,							__UpperCamelCase=512     ,							__UpperCamelCase=2     ,							__UpperCamelCase=0.02     ,							__UpperCamelCase=1e-12     ,							__UpperCamelCase=1     ,							__UpperCamelCase=0     ,							__UpperCamelCase=2     ,							__UpperCamelCase=768     ,							__UpperCamelCase=2     ,							__UpperCamelCase=9     ,							__UpperCamelCase=1     ,							__UpperCamelCase=None     ,							**__UpperCamelCase     ,							)       ->    Optional[int]:
          super().__init__(
              pad_token_id=__UpperCamelCase     ,							bos_token_id=__UpperCamelCase     ,							eos_token_id=__UpperCamelCase     ,							**__UpperCamelCase     ,							)

          _a						=		vocab_size
          _a						=		hidden_size
          _a						=		num_hidden_layers
          _a						=		num_attention_heads
          _a						=		intermediate_size
          _a						=		hidden_act
          _a						=		hidden_dropout_prob
          _a						=		attention_probs_dropout_prob
          _a						=		max_position_embeddings
          _a						=		type_vocab_size
          _a						=		initializer_range
          _a						=		layer_norm_eps
          _a						=		embedding_size
          _a						=		head_ratio
          _a						=		conv_kernel_size
          _a						=		num_groups
          _a						=		classifier_dropout







class 						__SCREAMING_SNAKE_CASE					(      lowerCamelCase__ ):






     @property
     def  a_					(			self		)       ->    Mapping[str, Mapping[int, str]]:
          if self.task == "multiple-choice":
               _a						=		{0: "batch", 1: "choice", 2: "sequence"}
          else:
               _a						=		{0: "batch", 1: "sequence"}
          return OrderedDict(
              [
                  ("input_ids", dynamic_axis),
                  ("attention_mask", dynamic_axis),
                  ("token_type_ids", dynamic_axis),
              ]		)

