






"""simple docstring"""






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


UpperCAmelCase_     :				Any         =				logging.get_logger(__name__)

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




class 							lowerCAmelCase__       (    UpperCAmelCase__				):






						'''simple docstring'''

						__UpperCamelCase							=						"nllb-moe"
						__UpperCamelCase							=						["past_key_values"]
						__UpperCamelCase							=						{"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}
						def __init__(		self  :						Dict		,			lowercase_  :						Optional[Any]=128112		,			lowercase_  :						Optional[Any]=1024		,			lowercase_  :						List[Any]=12		,			lowercase_  :						List[Any]=4096		,			lowercase_  :						str=16		,			lowercase_  :						Union[str, Any]=12		,			lowercase_  :						Union[str, Any]=4096		,			lowercase_  :						Optional[int]=16		,			lowercase_  :						int=0.05		,			lowercase_  :						str=0.05		,			lowercase_  :						Union[str, Any]=True		,			lowercase_  :						List[str]=True		,			lowercase_  :						List[Any]="relu"		,			lowercase_  :						Any=1024		,			lowercase_  :						str=0.1		,			lowercase_  :						Tuple=0.1		,			lowercase_  :						Dict=0.0		,			lowercase_  :						List[str]=0.02		,			lowercase_  :						Union[str, Any]=2		,			lowercase_  :						List[Any]=True		,			lowercase_  :						int=False		,			lowercase_  :						str="float32"		,			lowercase_  :						Optional[Any]=False		,			lowercase_  :						Optional[Any]=128		,			lowercase_  :						Optional[Any]=64		,			lowercase_  :						Union[str, Any]=4		,			lowercase_  :						List[Any]=4		,			lowercase_  :						str=0.0_01		,			lowercase_  :						Tuple=0.0_01		,			lowercase_  :						int="all"		,			lowercase_  :						Optional[Any]=False		,			lowercase_  :						Tuple=False		,			lowercase_  :						Tuple=1.0		,			lowercase_  :						str=0.2		,			lowercase_  :						Optional[int]=1		,			lowercase_  :						str=0		,			lowercase_  :						Union[str, Any]=2		,			lowercase_  :						Dict=False		,			**lowercase_  :						Tuple		,			):




										'''simple docstring'''


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

										SCREAMING_SNAKE_CASE_   :						List[Any]							=	router_ignore_padding_tokens
										SCREAMING_SNAKE_CASE_   :						Dict							=	batch_prioritized_routing
										SCREAMING_SNAKE_CASE_   :						str							=	second_expert_policy
										SCREAMING_SNAKE_CASE_   :						str							=	normalize_router_prob_before_dropping
										SCREAMING_SNAKE_CASE_   :						Tuple							=	moe_eval_capacity_token_fraction
										SCREAMING_SNAKE_CASE_   :						str							=	moe_token_dropout
										SCREAMING_SNAKE_CASE_   :						Dict							=	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"""






from __future__ import annotations



def       _A    (__a					,       __a					,       __a							)				-> int | float:
    """simple docstring"""






    if len(__a							) == 0:
        raise ValueError('''find_max() arg is an empty sequence'''							)
    if (
        left >= len(__a							)
        or left < -len(__a							)
        or right >= len(__a							)
        or right < -len(__a							)
    ):
        raise IndexError('''list index out of range'''							)
    if left == right:
        return nums[left]
    SCREAMING_SNAKE_CASE_   :						str							=	(left + right) >> 1  # the middle
    SCREAMING_SNAKE_CASE_   :						int							=	find_max(__a					,       __a					,       __a							)  # find max in range[left, mid]
    SCREAMING_SNAKE_CASE_   :						str							=	find_max(__a					,       mid + 1					,       __a							)  # find max in range[mid + 1, right]

    return left_max if left_max >= right_max else right_max


if __name__ == "__main__":
  import doctest

  doctest.testmod(verbose=True)


