




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


UpperCAmelCase_		:				Optional[Any]									=     logging.get_logger(__name__)

UpperCAmelCase_		:				List[Any]									=     {
    "facebook/nllb-moe-54B": "https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json",
}




class 		__A      (			UpperCamelCase__			):
						UpperCamelCase     						=					"""nllb-moe"""
						UpperCamelCase     						=					["""past_key_values"""]
						UpperCamelCase     						=					{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}

						def __init__(		self   :Dict    , __snake_case   :Optional[Any]=12_81_12    , __snake_case   :List[Any]=10_24    , __snake_case   :str=12    , __snake_case   :List[Any]=40_96    , __snake_case   :int=16    , __snake_case   :int=12    , __snake_case   :int=40_96    , __snake_case   :Any=16    , __snake_case   :Dict=0.05    , __snake_case   :int=0.05    , __snake_case   :Union[str, Any]=True    , __snake_case   :List[Any]=True    , __snake_case   :str="relu"    , __snake_case   :Tuple=10_24    , __snake_case   :Union[str, Any]=0.1    , __snake_case   :int=0.1    , __snake_case   :Optional[Any]=0.0    , __snake_case   :str=0.02    , __snake_case   :str=2    , __snake_case   :Optional[int]=True    , __snake_case   :Union[str, Any]=False    , __snake_case   :Any="float32"    , __snake_case   :List[str]=False    , __snake_case   :Optional[Any]=1_28    , __snake_case   :int=64    , __snake_case   :Optional[Any]=4    , __snake_case   :int=4    , __snake_case   :Optional[int]=0.001    , __snake_case   :str=0.001    , __snake_case   :str="all"    , __snake_case   :Dict=False    , __snake_case   :List[str]=False    , __snake_case   :Tuple=1.0    , __snake_case   :int=0.2    , __snake_case   :Tuple=1    , __snake_case   :Union[str, Any]=0    , __snake_case   :Tuple=2    , __snake_case   :int=False    , **__snake_case   :Dict    , ):
										'''simple docstring'''

										__magic_name__	:	Dict								=vocab_size
										__magic_name__	:	Tuple								=max_position_embeddings
										__magic_name__	:	Tuple								=d_model
										__magic_name__	:	List[Any]								=encoder_ffn_dim
										__magic_name__	:	Any								=encoder_layers
										__magic_name__	:	Optional[int]								=encoder_attention_heads
										__magic_name__	:	List[str]								=decoder_ffn_dim
										__magic_name__	:	List[Any]								=decoder_layers
										__magic_name__	:	Tuple								=decoder_attention_heads
										__magic_name__	:	int								=dropout
										__magic_name__	:	int								=attention_dropout
										__magic_name__	:	Optional[Any]								=activation_dropout
										__magic_name__	:	Optional[Any]								=activation_function
										__magic_name__	:	Optional[Any]								=init_std
										__magic_name__	:	List[Any]								=encoder_layerdrop
										__magic_name__	:	str								=decoder_layerdrop
										__magic_name__	:	str								=use_cache
										__magic_name__	:	Dict								=encoder_layers
										__magic_name__	:	Any								=scale_embedding  # scale factor will be sqrt(d_model) if True
										__magic_name__	:	Dict								=router_z_loss_coef
										__magic_name__	:	Tuple								=router_aux_loss_coef
										__magic_name__	:	Tuple								=decoder_sparse_step
										__magic_name__	:	List[Any]								=encoder_sparse_step
										__magic_name__	:	str								=num_experts
										__magic_name__	:	List[str]								=expert_capacity
										__magic_name__	:	Dict								=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}" )
										__magic_name__	:	List[Any]								=router_dtype

										__magic_name__	:	str								=router_ignore_padding_tokens
										__magic_name__	:	str								=batch_prioritized_routing
										__magic_name__	:	Any								=second_expert_policy
										__magic_name__	:	Optional[Any]								=normalize_router_prob_before_dropping
										__magic_name__	:	List[str]								=moe_eval_capacity_token_fraction
										__magic_name__	:	Any								=moe_token_dropout
										__magic_name__	:	Union[str, Any]								=output_router_logits
										super().__init__(
										    pad_token_id=__snake_case    , bos_token_id=__snake_case    , eos_token_id=__snake_case    , is_encoder_decoder=__snake_case    , decoder_start_token_id=__snake_case    , **__snake_case    , )










from math import pow, sqrt




def 		lowerCAmelCase_   (	*lowerCamelCase   ):
				__magic_name__	:	Tuple								=len(lowerCamelCase   ) > 0 and all(value > 0.0 for value in values   )
				return result




def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase   ):
				return (
				    round(sqrt(molar_mass_a / molar_mass_a   )	,     6   )
				    if validate(lowerCamelCase	,     lowerCamelCase   )
				    else ValueError("""Input Error: Molar mass values must greater than 0."""   )
				)




def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   ):
				return (
				    round(effusion_rate * sqrt(molar_mass_a / molar_mass_a   )	,     6   )
				    if validate(lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   )
				    else ValueError(
				        """Input Error: Molar mass and effusion rate values must greater than 0."""   )
				)




def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   ):
				return (
				    round(effusion_rate / sqrt(molar_mass_a / molar_mass_a   )	,     6   )
				    if validate(lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   )
				    else ValueError(
				        """Input Error: Molar mass and effusion rate values must greater than 0."""   )
				)




def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   ):
				return (
				    round(molar_mass / pow(effusion_rate_a / effusion_rate_a	,     2   )	,     6   )
				    if validate(lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   )
				    else ValueError(
				        """Input Error: Molar mass and effusion rate values must greater than 0."""   )
				)




def 		lowerCAmelCase_   (	lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   ):
				return (
				    round(pow(effusion_rate_a / effusion_rate_a	,     2   ) / molar_mass	,     6   )
				    if validate(lowerCamelCase	,     lowerCamelCase	,     lowerCamelCase   )
				    else ValueError(
				        """Input Error: Molar mass and effusion rate values must greater than 0."""   )
				)




