





from typing import Callable, Optional, Union

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


UpperCAmelCase	:	str		     =       logging.get_logger(__name__)

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







class 				__lowerCAmelCase       (    lowerCAmelCase_):
      _lowercase				:					Tuple						=			"xlm-prophetnet"
      _lowercase				:					Dict						=			["past_key_values"]
      _lowercase				:					int						=			{
          "num_attention_heads": "num_encoder_attention_heads",
      }







      def __init__(    self		,      lowerCAmelCase__ = 0.1		,      lowerCAmelCase__ = "gelu"		,      lowerCAmelCase__ = 3_0_5_2_2		,      lowerCAmelCase__ = 1_0_2_4		,      lowerCAmelCase__ = 4_0_9_6		,      lowerCAmelCase__ = 1_2		,      lowerCAmelCase__ = 1_6		,      lowerCAmelCase__ = 4_0_9_6		,      lowerCAmelCase__ = 1_2		,      lowerCAmelCase__ = 1_6		,      lowerCAmelCase__ = 0.1		,      lowerCAmelCase__ = 0.1		,      lowerCAmelCase__ = 5_1_2		,      lowerCAmelCase__ = 0.02		,      lowerCAmelCase__ = True		,      lowerCAmelCase__ = True		,      lowerCAmelCase__ = 0		,      lowerCAmelCase__ = 2		,      lowerCAmelCase__ = 3_2		,      lowerCAmelCase__ = 1_2_8		,      lowerCAmelCase__ = False		,      lowerCAmelCase__ = 0.0		,      lowerCAmelCase__ = True		,      lowerCAmelCase__ = 0		,      lowerCAmelCase__ = 1		,      lowerCAmelCase__ = 2		,      **lowerCAmelCase__		,      )   ->						Optional[Any]:



        '''simple docstring'''




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

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

        # 3 Types of Dropout
        a__	:					Optional[int]										=attention_dropout
        a__	:					Optional[int]										=activation_dropout
        a__	:					str										=dropout

        a__	:					int										=use_cache

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







      @property
      def    _lowercase  (    self							)   ->						int:



        '''simple docstring'''




        return self.num_encoder_layers + self.num_decoder_layers







      @num_hidden_layers.setter
      def    _lowercase  (    self		,      lowerCAmelCase__							)   ->						Dict:



        '''simple docstring'''




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













import importlib
import shutil
import threading
import warnings
from typing import List

import fsspec
import fsspec.asyn

from . import compression
from .hffilesystem import HfFileSystem


SCREAMING_SNAKE_CASE_						   =       importlib.util.find_spec("""s3fs""") is not None

if _has_safs:
      from .safilesystem import SaFileSystem  # noqa: F401

SCREAMING_SNAKE_CASE_						   =       [
    compression.BzaFileSystem,
    compression.GzipFileSystem,
    compression.LzaFileSystem,
    compression.XzFileSystem,
    compression.ZstdFileSystem,
]

# Register custom filesystems
for fs_class in COMPRESSION_FILESYSTEMS + [HfFileSystem]:
      if fs_class.protocol in fsspec.registry and fsspec.registry[fs_class.protocol] is not fs_class:
            warnings.warn(F'''A filesystem protocol was already set for {fs_class.protocol} and will be overwritten.''')
      fsspec.register_implementation(fs_class.protocol, fs_class, clobber=True)



def    __lowercase   (      _SCREAMING_SNAKE_CASE	) ->   str:


      '''simple docstring'''


      if "://" in dataset_path:
            SCREAMING_SNAKE_CASE		=						dataset_path.split("""://"""	)[1]
      return dataset_path



def    __lowercase   (      _SCREAMING_SNAKE_CASE	) ->   bool:


      '''simple docstring'''


      if fs is not None and fs.protocol != "file":
            return True
      else:
            return False



def    __lowercase   (      _SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE	) ->   Dict:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE		=						not is_remote_filesystem(_SCREAMING_SNAKE_CASE	)
      if is_local:
            # LocalFileSystem.mv does copy + rm, it is more efficient to simply move a local directory
            shutil.move(fs._strip_protocol(_SCREAMING_SNAKE_CASE	) ,						fs._strip_protocol(_SCREAMING_SNAKE_CASE	)	)
      else:
            fs.mv(_SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE ,						recursive=_SCREAMING_SNAKE_CASE	)



def    __lowercase   (      ) ->   None:


      '''simple docstring'''


      if hasattr(fsspec.asyn ,						"""reset_lock"""	):
            # for future fsspec>2022.05.0
            fsspec.asyn.reset_lock()
      else:
            SCREAMING_SNAKE_CASE		=						None
            SCREAMING_SNAKE_CASE		=						None
            SCREAMING_SNAKE_CASE		=						threading.Lock()


