






from collections import OrderedDict
from typing import Mapping

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


A_						:						Union[str, Any]						      =					logging.get_logger(__name__)

A_						:						int						      =					{
    'xlm-mlm-en-2048': 'https://huggingface.co/xlm-mlm-en-2048/resolve/main/config.json',
    'xlm-mlm-ende-1024': 'https://huggingface.co/xlm-mlm-ende-1024/resolve/main/config.json',
    'xlm-mlm-enfr-1024': 'https://huggingface.co/xlm-mlm-enfr-1024/resolve/main/config.json',
    'xlm-mlm-enro-1024': 'https://huggingface.co/xlm-mlm-enro-1024/resolve/main/config.json',
    'xlm-mlm-tlm-xnli15-1024': 'https://huggingface.co/xlm-mlm-tlm-xnli15-1024/resolve/main/config.json',
    'xlm-mlm-xnli15-1024': 'https://huggingface.co/xlm-mlm-xnli15-1024/resolve/main/config.json',
    'xlm-clm-enfr-1024': 'https://huggingface.co/xlm-clm-enfr-1024/resolve/main/config.json',
    'xlm-clm-ende-1024': 'https://huggingface.co/xlm-clm-ende-1024/resolve/main/config.json',
    'xlm-mlm-17-1280': 'https://huggingface.co/xlm-mlm-17-1280/resolve/main/config.json',
    'xlm-mlm-100-1280': 'https://huggingface.co/xlm-mlm-100-1280/resolve/main/config.json',
}




class 							_lowerCAmelCase(			UpperCAmelCase_   ):





       """simple docstring"""







       a							:						int										='''xlm'''
       a							:						str										={
           '''hidden_size''': '''emb_dim''',
           '''num_attention_heads''': '''n_heads''',
           '''num_hidden_layers''': '''n_layers''',
           '''n_words''': '''vocab_size''',  # For backward compatibility
       }





       def __init__(   self    ,     _lowerCamelCase=3_0_1_4_5    ,     _lowerCamelCase=2_0_4_8    ,     _lowerCamelCase=1_2    ,     _lowerCamelCase=1_6    ,     _lowerCamelCase=0.1    ,     _lowerCamelCase=0.1    ,     _lowerCamelCase=True    ,     _lowerCamelCase=False    ,     _lowerCamelCase=False    ,     _lowerCamelCase=False    ,     _lowerCamelCase=1    ,     _lowerCamelCase=True    ,     _lowerCamelCase=5_1_2    ,     _lowerCamelCase=2_0_4_8**-0.5    ,     _lowerCamelCase=1e-12    ,     _lowerCamelCase=0.0_2    ,     _lowerCamelCase=0    ,     _lowerCamelCase=1    ,     _lowerCamelCase=2    ,     _lowerCamelCase=3    ,     _lowerCamelCase=5    ,     _lowerCamelCase=True    ,     _lowerCamelCase="first"    ,     _lowerCamelCase=True    ,     _lowerCamelCase=None    ,     _lowerCamelCase=True    ,     _lowerCamelCase=0.1    ,     _lowerCamelCase=5    ,     _lowerCamelCase=5    ,     _lowerCamelCase=0    ,     _lowerCamelCase=0    ,     _lowerCamelCase=2    ,     _lowerCamelCase=0    ,     **_lowerCamelCase    ,     ):
         UpperCamelCase_:   Any        =							vocab_size
         UpperCamelCase_:   Any        =							emb_dim
         UpperCamelCase_:   Optional[int]        =							n_layers
         UpperCamelCase_:   int        =							n_heads
         UpperCamelCase_:   Optional[int]        =							dropout
         UpperCamelCase_:   Tuple        =							attention_dropout
         UpperCamelCase_:   List[Any]        =							gelu_activation
         UpperCamelCase_:   Optional[int]        =							sinusoidal_embeddings
         UpperCamelCase_:   Any        =							causal
         UpperCamelCase_:   Tuple        =							asm
         UpperCamelCase_:   Optional[Any]        =							n_langs
         UpperCamelCase_:   int        =							use_lang_emb
         UpperCamelCase_:   Optional[Any]        =							layer_norm_eps
         UpperCamelCase_:   Any        =							bos_index
         UpperCamelCase_:   Any        =							eos_index
         UpperCamelCase_:   Optional[int]        =							pad_index
         UpperCamelCase_:   List[str]        =							unk_index
         UpperCamelCase_:   Optional[Any]        =							mask_index
         UpperCamelCase_:   Optional[int]        =							is_encoder
         UpperCamelCase_:   Any        =							max_position_embeddings
         UpperCamelCase_:   List[Any]        =							embed_init_std
         UpperCamelCase_:   Union[str, Any]        =							init_std
         UpperCamelCase_:   Dict        =							summary_type
         UpperCamelCase_:   Optional[int]        =							summary_use_proj
         UpperCamelCase_:   Dict        =							summary_activation
         UpperCamelCase_:   Dict        =							summary_proj_to_labels
         UpperCamelCase_:   List[Any]        =							summary_first_dropout
         UpperCamelCase_:   Dict        =							start_n_top
         UpperCamelCase_:   Optional[Any]        =							end_n_top
         UpperCamelCase_:   List[Any]        =							mask_token_id
         UpperCamelCase_:   Optional[int]        =							lang_id

         if "n_words" in kwargs:
           UpperCamelCase_:   str        =							kwargs['n_words']

         super().__init__(pad_token_id=_lowerCamelCase    ,     bos_token_id=_lowerCamelCase    ,     **_lowerCamelCase				)







class 							_lowerCAmelCase(			UpperCAmelCase_   ):





       """simple docstring"""







       @property
       def      _a       (   self				):
         if self.task == "multiple-choice":
           UpperCamelCase_:   List[str]        =							{0: 'batch', 1: 'choice', 2: 'sequence'}
         else:
           UpperCamelCase_:   Union[str, Any]        =							{0: 'batch', 1: 'sequence'}
         return OrderedDict(
             [
                 ('input_ids', dynamic_axis),
                 ('attention_mask', dynamic_axis),
                 ('token_type_ids', dynamic_axis),
             ]				)






'''simple docstring'''

from pathlib import PurePosixPath
from typing import Optional

import fsspec
from fsspec import AbstractFileSystem
from huggingface_hub.hf_api import DatasetInfo

from ..utils.file_utils import get_authentication_headers_for_url
from ..utils.hub import hf_hub_url







class __a			( _snake_case      ):
   __UpperCamelCase :			Any						   =						''
   __UpperCamelCase :			int						   =						'hf-legacy'  # "hf://"" is reserved for hffs





   def __init__(       self					:      Any					,lowerCamelCase					:      Optional[DatasetInfo] = None					,lowerCamelCase					:      Optional[str] = None					,**lowerCamelCase					:      Dict					,):

      '''simple docstring'''

      super().__init__(self					,**lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							repo_info
      __SCREAMING_SNAKE_CASE   				=							token
      __SCREAMING_SNAKE_CASE   				=							None





   def   UpperCAmelCase__  (       self					:      Optional[int]     ):

      '''simple docstring'''

      if self.dir_cache is None:
         __SCREAMING_SNAKE_CASE   				=							{}
         for hf_file in self.repo_info.siblings:
            # TODO(QL): add sizes
            __SCREAMING_SNAKE_CASE   				=							{
                """name""": hf_file.rfilename,
                """size""": None,
                """type""": """file""",
            }
            self.dir_cache.update(
                {
                    str(lowerCamelCase     ): {"""name""": str(lowerCamelCase     ), """size""": None, """type""": """directory"""}
                    for d in list(PurePosixPath(hf_file.rfilename     ).parents     )[:-1]
                }     )





   def   UpperCAmelCase__  (       self					:      List[Any]					,lowerCamelCase					:      str					,lowerCamelCase					:      str = "rb"					,**lowerCamelCase					:      Optional[Any]					,):

      '''simple docstring'''

      if not isinstance(self.repo_info					,lowerCamelCase     ):
         raise NotImplementedError(f"""Open is only implemented for dataset repositories, but got {self.repo_info}"""     )
      __SCREAMING_SNAKE_CASE   				=							hf_hub_url(self.repo_info.id					,lowerCamelCase					,revision=self.repo_info.sha     )
      return fsspec.open(
          lowerCamelCase					,mode=lowerCamelCase					,headers=get_authentication_headers_for_url(lowerCamelCase					,use_auth_token=self.token     )					,client_kwargs={"""trust_env""": True}					,).open()





   def   UpperCAmelCase__  (       self					:      Tuple					,lowerCamelCase					:      Any					,**lowerCamelCase					:      Optional[Any]     ):

      '''simple docstring'''

      self._get_dirs()
      __SCREAMING_SNAKE_CASE   				=							self._strip_protocol(lowerCamelCase     )
      if path in self.dir_cache:
         return self.dir_cache[path]
      else:
         raise FileNotFoundError(lowerCamelCase     )





   def   UpperCAmelCase__  (       self					:      str					,lowerCamelCase					:      Any					,lowerCamelCase					:      str=False					,**lowerCamelCase					:      Any     ):

      '''simple docstring'''

      self._get_dirs()
      __SCREAMING_SNAKE_CASE   				=							PurePosixPath(path.strip("""/"""     )     )
      __SCREAMING_SNAKE_CASE   				=							{}
      for p, f in self.dir_cache.items():
         __SCREAMING_SNAKE_CASE   				=							PurePosixPath(p.strip("""/"""     )     )
         __SCREAMING_SNAKE_CASE   				=							p.parent
         if root == path:
            __SCREAMING_SNAKE_CASE   				=							f
      __SCREAMING_SNAKE_CASE   				=							list(paths.values()     )
      if detail:
         return out
      else:
         return sorted(f["""name"""] for f in out     )





