




"""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 							lowercase_			(	__lowerCAmelCase				):



 '''simple docstring'''
 UpperCAmelCase       :	str     =      '''nllb-moe'''
 UpperCAmelCase       :	Optional[int]     =      ['''past_key_values''']
 UpperCAmelCase       :	Union[str, Any]     =      {'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}

 def __init__(					self			:			Optional[int]       ,				_UpperCAmelCase			:			Union[str, Any]=128_112       ,				_UpperCAmelCase			:			Optional[Any]=1_024       ,				_UpperCAmelCase			:			List[str]=12       ,				_UpperCAmelCase			:			Union[str, Any]=4_096       ,				_UpperCAmelCase			:			Tuple=16       ,				_UpperCAmelCase			:			Union[str, Any]=12       ,				_UpperCAmelCase			:			Dict=4_096       ,				_UpperCAmelCase			:			int=16       ,				_UpperCAmelCase			:			Any=0.05       ,				_UpperCAmelCase			:			List[str]=0.05       ,				_UpperCAmelCase			:			int=True       ,				_UpperCAmelCase			:			Dict=True       ,				_UpperCAmelCase			:			Any="relu"       ,				_UpperCAmelCase			:			Tuple=1_024       ,				_UpperCAmelCase			:			Dict=0.1       ,				_UpperCAmelCase			:			Tuple=0.1       ,				_UpperCAmelCase			:			List[str]=0.0       ,				_UpperCAmelCase			:			Tuple=0.02       ,				_UpperCAmelCase			:			List[Any]=2       ,				_UpperCAmelCase			:			int=True       ,				_UpperCAmelCase			:			Tuple=False       ,				_UpperCAmelCase			:			Dict="float32"       ,				_UpperCAmelCase			:			Union[str, Any]=False       ,				_UpperCAmelCase			:			Optional[Any]=128       ,				_UpperCAmelCase			:			List[Any]=64       ,				_UpperCAmelCase			:			Union[str, Any]=4       ,				_UpperCAmelCase			:			Tuple=4       ,				_UpperCAmelCase			:			Tuple=0.001       ,				_UpperCAmelCase			:			Union[str, Any]=0.001       ,				_UpperCAmelCase			:			Dict="all"       ,				_UpperCAmelCase			:			Optional[Any]=False       ,				_UpperCAmelCase			:			Tuple=False       ,				_UpperCAmelCase			:			Optional[Any]=1.0       ,				_UpperCAmelCase			:			int=0.2       ,				_UpperCAmelCase			:			Optional[Any]=1       ,				_UpperCAmelCase			:			str=0       ,				_UpperCAmelCase			:			List[str]=2       ,				_UpperCAmelCase			:			Union[str, Any]=False       ,				**_UpperCAmelCase			:			List[Any]       ,				):
       _A     =  vocab_size
       _A     =  max_position_embeddings
       _A     =  d_model
       _A     =  encoder_ffn_dim
       _A     =  encoder_layers
       _A     =  encoder_attention_heads
       _A     =  decoder_ffn_dim
       _A     =  decoder_layers
       _A     =  decoder_attention_heads
       _A     =  dropout
       _A     =  attention_dropout
       _A     =  activation_dropout
       _A     =  activation_function
       _A     =  init_std
       _A     =  encoder_layerdrop
       _A     =  decoder_layerdrop
       _A     =  use_cache
       _A     =  encoder_layers
       _A     =  scale_embedding  # scale factor will be sqrt(d_model) if True
       _A     =  router_z_loss_coef
       _A     =  router_aux_loss_coef
       _A     =  decoder_sparse_step
       _A     =  encoder_sparse_step
       _A     =  num_experts
       _A     =  expert_capacity
       _A     =  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}'''						)
       _A     =  router_dtype

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




import enum
import os
from hashlib import shaaaa
from typing import Optional

from .. import config
from .logging import get_logger


UpperCamelCase__		 =     get_logger(__name__)

class     __snake_case    (				enum.Enum  ):
       """simple docstring"""







       __SCREAMING_SNAKE_CASE				    =							"all_checks"
       __SCREAMING_SNAKE_CASE				    =							"basic_checks"
       __SCREAMING_SNAKE_CASE				    =							"no_checks"






class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""














def 						lowerCamelCase__      ( __A    :Optional[dict]	,__A    :dict	,__A    :Any=None		):


       """simple docstring"""




       if expected_checksums is None:
              logger.info("""Unable to verify checksums."""		)
              return
       if len(set(__A		) - set(__A		)		) > 0:
              raise ExpectedMoreDownloadedFiles(str(set(__A		) - set(__A		)		)		)
       if len(set(__A		) - set(__A		)		) > 0:
              raise UnexpectedDownloadedFile(str(set(__A		) - set(__A		)		)		)
       __snake_case       	=							[url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
       __snake_case       	=							""" for """ + verification_name if verification_name is not None else """"""
       if len(__A		) > 0:
              raise NonMatchingChecksumError(
                  F'Checksums didn\'t match{for_verification_name}:\n'
                  F'{bad_urls}\n'
                  """Set `verification_mode='no_checks'` to skip checksums verification and ignore this error"""		)
       logger.info("""All the checksums matched successfully""" + for_verification_name		)

class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""













class     __snake_case    (				snake_case__  ):
       """simple docstring"""














def 						lowerCamelCase__      ( __A    :Optional[dict]	,__A    :dict		):


       """simple docstring"""




       if expected_splits is None:
              logger.info("""Unable to verify splits sizes."""		)
              return
       if len(set(__A		) - set(__A		)		) > 0:
              raise ExpectedMoreSplits(str(set(__A		) - set(__A		)		)		)
       if len(set(__A		) - set(__A		)		) > 0:
              raise UnexpectedSplits(str(set(__A		) - set(__A		)		)		)
       __snake_case       	=							[
           {"""expected""": expected_splits[name], """recorded""": recorded_splits[name]}
           for name in expected_splits
           if expected_splits[name].num_examples != recorded_splits[name].num_examples
       ]
       if len(__A		) > 0:
              raise NonMatchingSplitsSizesError(str(__A		)		)
       logger.info("""All the splits matched successfully."""		)







def 						lowerCamelCase__      ( __A    :str	,__A    :bool = True		):


       """simple docstring"""




       if record_checksum:
              __snake_case       	=							shaaaa()
              with open(__A	,"""rb"""		) as f:
                     for chunk in iter(lambda: f.read(1 << 2_0		)	,b""""""		):
                            m.update(__A		)
                     __snake_case       	=							m.hexdigest()
       else:
              __snake_case       	=							None
       return {"num_bytes": os.path.getsize(__A		), "checksum": checksum}







def 						lowerCamelCase__      ( __A    :Optional[int]		):


       """simple docstring"""




       if dataset_size and config.IN_MEMORY_MAX_SIZE:
              return dataset_size < config.IN_MEMORY_MAX_SIZE
       else:
              return False

