





'''simple docstring'''

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


a   	=    logging.get_logger(__name__)

a   	=    {
    "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json",
}







class __a			( _snake_case      ):
   __UpperCamelCase :			List[Any]						   =						'nllb-moe'
   __UpperCamelCase :			Dict						   =						['past_key_values']
   __UpperCamelCase :			Union[str, Any]						   =						{'num_attention_heads': 'encoder_attention_heads', 'hidden_size': 'd_model'}





   def __init__(       self					:      str					,lowerCamelCase					:      Optional[Any]=12_8112					,lowerCamelCase					:      List[str]=1024					,lowerCamelCase					:      Any=12					,lowerCamelCase					:      str=4096					,lowerCamelCase					:      Optional[Any]=16					,lowerCamelCase					:      Optional[Any]=12					,lowerCamelCase					:      int=4096					,lowerCamelCase					:      Tuple=16					,lowerCamelCase					:      str=0.05					,lowerCamelCase					:      Union[str, Any]=0.05					,lowerCamelCase					:      Union[str, Any]=True					,lowerCamelCase					:      Optional[Any]=True					,lowerCamelCase					:      List[str]="relu"					,lowerCamelCase					:      int=1024					,lowerCamelCase					:      List[Any]=0.1					,lowerCamelCase					:      str=0.1					,lowerCamelCase					:      Union[str, Any]=0.0					,lowerCamelCase					:      Tuple=0.02					,lowerCamelCase					:      Tuple=2					,lowerCamelCase					:      Union[str, Any]=True					,lowerCamelCase					:      Optional[Any]=False					,lowerCamelCase					:      Union[str, Any]="float32"					,lowerCamelCase					:      List[str]=False					,lowerCamelCase					:      int=128					,lowerCamelCase					:      List[Any]=64					,lowerCamelCase					:      List[str]=4					,lowerCamelCase					:      Dict=4					,lowerCamelCase					:      List[str]=0.001					,lowerCamelCase					:      str=0.001					,lowerCamelCase					:      Any="all"					,lowerCamelCase					:      Dict=False					,lowerCamelCase					:      Union[str, Any]=False					,lowerCamelCase					:      Tuple=1.0					,lowerCamelCase					:      Tuple=0.2					,lowerCamelCase					:      str=1					,lowerCamelCase					:      Dict=0					,lowerCamelCase					:      Optional[int]=2					,lowerCamelCase					:      Dict=False					,**lowerCamelCase					:      int					,):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							vocab_size
      __SCREAMING_SNAKE_CASE   				=							max_position_embeddings
      __SCREAMING_SNAKE_CASE   				=							d_model
      __SCREAMING_SNAKE_CASE   				=							encoder_ffn_dim
      __SCREAMING_SNAKE_CASE   				=							encoder_layers
      __SCREAMING_SNAKE_CASE   				=							encoder_attention_heads
      __SCREAMING_SNAKE_CASE   				=							decoder_ffn_dim
      __SCREAMING_SNAKE_CASE   				=							decoder_layers
      __SCREAMING_SNAKE_CASE   				=							decoder_attention_heads
      __SCREAMING_SNAKE_CASE   				=							dropout
      __SCREAMING_SNAKE_CASE   				=							attention_dropout
      __SCREAMING_SNAKE_CASE   				=							activation_dropout
      __SCREAMING_SNAKE_CASE   				=							activation_function
      __SCREAMING_SNAKE_CASE   				=							init_std
      __SCREAMING_SNAKE_CASE   				=							encoder_layerdrop
      __SCREAMING_SNAKE_CASE   				=							decoder_layerdrop
      __SCREAMING_SNAKE_CASE   				=							use_cache
      __SCREAMING_SNAKE_CASE   				=							encoder_layers
      __SCREAMING_SNAKE_CASE   				=							scale_embedding  # scale factor will be sqrt(d_model) if True
      __SCREAMING_SNAKE_CASE   				=							router_z_loss_coef
      __SCREAMING_SNAKE_CASE   				=							router_aux_loss_coef
      __SCREAMING_SNAKE_CASE   				=							decoder_sparse_step
      __SCREAMING_SNAKE_CASE   				=							encoder_sparse_step
      __SCREAMING_SNAKE_CASE   				=							num_experts
      __SCREAMING_SNAKE_CASE   				=							expert_capacity
      __SCREAMING_SNAKE_CASE   				=							router_bias
      if router_dtype not in ["float32", "float16", "bfloat16"]:
         raise ValueError(f"""`router_dtype` must be one of 'float32', 'float16' or 'bfloat16', got {router_dtype}"""     )
      __SCREAMING_SNAKE_CASE   				=							router_dtype

      __SCREAMING_SNAKE_CASE   				=							router_ignore_padding_tokens
      __SCREAMING_SNAKE_CASE   				=							batch_prioritized_routing
      __SCREAMING_SNAKE_CASE   				=							second_expert_policy
      __SCREAMING_SNAKE_CASE   				=							normalize_router_prob_before_dropping
      __SCREAMING_SNAKE_CASE   				=							moe_eval_capacity_token_fraction
      __SCREAMING_SNAKE_CASE   				=							moe_token_dropout
      __SCREAMING_SNAKE_CASE   				=							output_router_logits
      super().__init__(
          pad_token_id=lowerCamelCase					,bos_token_id=lowerCamelCase					,eos_token_id=lowerCamelCase					,is_encoder_decoder=lowerCamelCase					,decoder_start_token_id=lowerCamelCase					,**lowerCamelCase					,)









"""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     _UpperCamelCase    (  lowerCAmelCase__						):
							'''simple docstring'''







							__UpperCAmelCase		:       Union[str, Any]							 =""""""
							__UpperCAmelCase		:       Optional[int]							 ="""hf-legacy"""  # "hf://"" is reserved for hffs

							def __init__(	self       ,  __a = None       ,  __a = None       ,  **__a       ,  ):
										super().__init__(self       ,  **__a      )
										__lowerCAmelCase							       =     repo_info
										__lowerCAmelCase							       =     token
										__lowerCAmelCase							       =     None

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

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

							def      snake_case							(	self       ,  __a       ,  **__a      ):
										self._get_dirs()
										__lowerCAmelCase							       =     self._strip_protocol(__a      )
										if path in self.dir_cache:
													return self.dir_cache[path]
										else:
													raise FileNotFoundError(__a      )



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




