


"""simple docstring"""







from typing import Callable, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase__				    =       logging.get_logger(__name__)

lowerCAmelCase__				    =       {
    '''microsoft/xprophetnet-large-wiki100-cased''': (
        '''https://huggingface.co/microsoft/xprophetnet-large-wiki100-cased/resolve/main/config.json'''
    ),
}


class 				SCREAMING_SNAKE_CASE__    (		lowerCamelCase_    ):
       """simple docstring"""


       a  :    List[Any]       ="""xlm-prophetnet"""
       a  :    List[Any]       =["""past_key_values"""]
       a  :    List[Any]       ={
           """num_attention_heads""": """num_encoder_attention_heads""",
       }

       def __init__(						self		,					snake_case__ = 0.1		,					snake_case__ = "gelu"		,					snake_case__ = 30_522		,					snake_case__ = 1_024		,					snake_case__ = 4_096		,					snake_case__ = 12		,					snake_case__ = 16		,					snake_case__ = 4_096		,					snake_case__ = 12		,					snake_case__ = 16		,					snake_case__ = 0.1		,					snake_case__ = 0.1		,					snake_case__ = 512		,					snake_case__ = 0.02		,					snake_case__ = True		,					snake_case__ = True		,					snake_case__ = 0		,					snake_case__ = 2		,					snake_case__ = 32		,					snake_case__ = 128		,					snake_case__ = False		,					snake_case__ = 0.0		,					snake_case__ = True		,					snake_case__ = 0		,					snake_case__ = 1		,					snake_case__ = 2		,					**snake_case__		,					):






         """simple docstring"""





         lowerCAmelCase					:					List[Any]								=							vocab_size
         lowerCAmelCase					:					List[str]								=							hidden_size
         lowerCAmelCase					:					List[str]								=							encoder_ffn_dim
         lowerCAmelCase					:					Union[str, Any]								=							num_encoder_layers
         lowerCAmelCase					:					Tuple								=							num_encoder_attention_heads
         lowerCAmelCase					:					Union[str, Any]								=							decoder_ffn_dim
         lowerCAmelCase					:					int								=							num_decoder_layers
         lowerCAmelCase					:					List[Any]								=							num_decoder_attention_heads
         lowerCAmelCase					:					int								=							max_position_embeddings
         lowerCAmelCase					:					Tuple								=							init_std  # Normal(0, this parameter)
         lowerCAmelCase					:					List[Any]								=							activation_function

         # parameters for xlmprophetnet
         lowerCAmelCase					:					List[Any]								=							ngram
         lowerCAmelCase					:					Optional[Any]								=							num_buckets
         lowerCAmelCase					:					Tuple								=							relative_max_distance
         lowerCAmelCase					:					List[Any]								=							disable_ngram_loss
         lowerCAmelCase					:					str								=							eps

         # 3 Types of Dropout
         lowerCAmelCase					:					Dict								=							attention_dropout
         lowerCAmelCase					:					Optional[int]								=							activation_dropout
         lowerCAmelCase					:					Optional[Any]								=							dropout

         lowerCAmelCase					:					Any								=							use_cache

         super().__init__(
             pad_token_id=_UpperCAmelCase		,					bos_token_id=_UpperCAmelCase		,					eos_token_id=_UpperCAmelCase		,					is_encoder_decoder=_UpperCAmelCase		,					add_cross_attention=_UpperCAmelCase		,					decoder_start_token_id=_UpperCAmelCase		,					**_UpperCAmelCase		,					)

       @property
       def 	lowercase__							(						self						):






         """simple docstring"""





         return self.num_encoder_layers + self.num_decoder_layers







       @num_hidden_layers.setter
       def 	lowercase__							(						self		,					snake_case__						):






         """simple docstring"""





         raise NotImplementedError(
             "This model does not support the setting of `num_hidden_layers`. Please set `num_encoder_layers` and"
             " `num_decoder_layers`."						)









"""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  a__      (    SCREAMING_SNAKE_CASE   :   str    ):  # 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"

  lowerCAmelCase					:					List[str]								=							[1, 2, 3]
  with pytest.raises(SCREAMING_SNAKE_CASE    ):
    with parallel_backend("unsupported backend"    ):
      map_nested(SCREAMING_SNAKE_CASE    ,				SCREAMING_SNAKE_CASE    ,				num_proc=2    )

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





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


  '''simple docstring'''







  lowerCAmelCase					:					Tuple								=							[1, 2]
  lowerCAmelCase					:					int								=							{"a": 1, "b": 2}
  lowerCAmelCase					:					List[str]								=							{"a": [1, 2], "b": [3, 4]}
  lowerCAmelCase					:					Dict								=							{"a": {"1": 1}, "b": 2}
  lowerCAmelCase					:					Tuple								=							{"a": 1, "b": 2, "c": 3, "d": 4}
  lowerCAmelCase					:					Any								=							[2, 3]
  lowerCAmelCase					:					Any								=							{"a": 2, "b": 3}
  lowerCAmelCase					:					Optional[int]								=							{"a": [2, 3], "b": [4, 5]}
  lowerCAmelCase					:					Optional[int]								=							{"a": {"1": 2}, "b": 3}
  lowerCAmelCase					:					str								=							{"a": 2, "b": 3, "c": 4, "d": 5}

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





