




"""simple docstring"""






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


lowercase__  		=		logging.get_logger(__name__)

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






class lowerCAmelCase__			(  lowercase		):






   '''simple docstring'''



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

       _lowerCamelCase  :    Optional[Any]					=					router_ignore_padding_tokens
       _lowerCamelCase  :    Union[str, Any]					=					batch_prioritized_routing
       _lowerCamelCase  :    Optional[Any]					=					second_expert_policy
       _lowerCamelCase  :    int					=					normalize_router_prob_before_dropping
       _lowerCamelCase  :    Any					=					moe_eval_capacity_token_fraction
       _lowerCamelCase  :    Dict					=					moe_token_dropout
       _lowerCamelCase  :    Union[str, Any]					=					output_router_logits
       super().__init__(
           pad_token_id=lowercase						,   bos_token_id=lowercase						,   eos_token_id=lowercase						,   is_encoder_decoder=lowercase						,   decoder_start_token_id=lowercase						,   **lowercase						,   )





"""simple docstring"""






def   _snake_case    (       lowercase__	):
				_lowerCamelCase  :    List[str]					=					abs(lowercase__	)
				_lowerCamelCase  :    Optional[int]					=					0
				while n > 0:
								res += n % 10
								n //= 10
				return res







def   _snake_case    (       lowercase__	):
				_lowerCamelCase  :    List[str]					=					abs(lowercase__	)
				return n if n < 10 else n % 10 + sum_of_digits(n // 10	)







def   _snake_case    (       lowercase__	):
				return sum(int(lowercase__	) for c in str(abs(lowercase__	)	)	)







def   _snake_case    (       ):
				from collections.abc import Callable
				from timeit import timeit

				def benchmark_a_function(lowercase__							,					lowercase__	) -> None:
								_lowerCamelCase  :    int					=					f'''{func.__name__}({value})'''
								_lowerCamelCase  :    Optional[Any]					=					timeit(f'''__main__.{call}'''							,					setup='import __main__'	)
								print(f'''{call:56} = {func(lowercase__	)} -- {timing:.4f} seconds'''	)

				for value in (262144, 1125899906842624, 1267650600228229401496703205376):
								for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
												benchmark_a_function(lowercase__							,					lowercase__	)
								print()


if __name__ == "__main__":
			import doctest

			doctest.testmod()
			benchmark()