



"""simple docstring"""





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


__lowerCAmelCase       :					Union[str, Any]      					=					logging.get_logger(__name__)

__lowerCAmelCase       :					Optional[int]      					=					{
    '''facebook/nllb-moe-54B''': '''https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json''',
}



class    _lowerCAmelCase    (				SCREAMING_SNAKE_CASE__		):





		"""simple docstring"""






		_lowerCamelCase			  =       '''nllb-moe'''
		_lowerCamelCase			  =       ['''past_key_values''']
		_lowerCamelCase			  =       {'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}





		def __init__(					self							,    _lowercase=1_2_8_1_1_2							,    _lowercase=1_0_2_4							,    _lowercase=1_2							,    _lowercase=4_0_9_6							,    _lowercase=1_6							,    _lowercase=1_2							,    _lowercase=4_0_9_6							,    _lowercase=1_6							,    _lowercase=0.05							,    _lowercase=0.05							,    _lowercase=True							,    _lowercase=True							,    _lowercase="relu"							,    _lowercase=1_0_2_4							,    _lowercase=0.1							,    _lowercase=0.1							,    _lowercase=0.0							,    _lowercase=0.02							,    _lowercase=2							,    _lowercase=True							,    _lowercase=False							,    _lowercase="float32"							,    _lowercase=False							,    _lowercase=1_2_8							,    _lowercase=6_4							,    _lowercase=4							,    _lowercase=4							,    _lowercase=0.001							,    _lowercase=0.001							,    _lowercase="all"							,    _lowercase=False							,    _lowercase=False							,    _lowercase=1.0							,    _lowercase=0.2							,    _lowercase=1							,    _lowercase=0							,    _lowercase=2							,    _lowercase=False							,    **_lowercase							,    ) ->						Optional[int]:







								'''simple docstring'''

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

								snake_case_   : Optional[Any]						=			router_ignore_padding_tokens
								snake_case_   : Union[str, Any]						=			batch_prioritized_routing
								snake_case_   : List[str]						=			second_expert_policy
								snake_case_   : Optional[Any]						=			normalize_router_prob_before_dropping
								snake_case_   : List[Any]						=			moe_eval_capacity_token_fraction
								snake_case_   : List[Any]						=			moe_token_dropout
								snake_case_   : Tuple						=			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 collections.abc import Callable
from math import pi, sqrt
from random import uniform
from statistics import mean
def 	__lowerCAmelCase						(		__UpperCamelCase      :			int    ):


						'''simple docstring'''






						def is_in_circle(__UpperCamelCase      :			float					, __UpperCamelCase      :			float    ) -> bool:
												snake_case_   : Dict						=			sqrt((x**2) + (y**2)    )
												# Our circle has a radius of 1, so a distance
												# greater than 1 would land outside the circle.
												return distance_from_centre <= 1

						# The proportion of guesses that landed in the circle
						snake_case_   : Tuple						=			mean(
						    int(is_in_circle(uniform(-1.0					, 1.0    )					, uniform(-1.0					, 1.0    )    )    )
						    for _ in range(__UpperCamelCase    )    )
						# The ratio of the area for circle to square is pi/4.
						snake_case_   : Union[str, Any]						=			proportion * 4
						print(F'The estimated value of pi is {pi_estimate}'    )
						print(F'The numpy value of pi is {pi}'    )
						print(F'The total error is {abs(pi - pi_estimate    )}'    )
def 	__lowerCAmelCase						(		__UpperCamelCase      :			int					, __UpperCamelCase      :			Callable[[float], float]					, __UpperCamelCase      :			float = 0.0					, __UpperCamelCase      :			float = 1.0					, ):


						'''simple docstring'''






						return mean(
						    function_to_integrate(uniform(__UpperCamelCase					, __UpperCamelCase    )    ) for _ in range(__UpperCamelCase    )    ) * (max_value - min_value)
def 	__lowerCAmelCase						(		__UpperCamelCase      :			int					, __UpperCamelCase      :			float = 0.0					, __UpperCamelCase      :			float = 1.0    ):


						'''simple docstring'''






						def identity_function(__UpperCamelCase      :			float    ) -> float:
												return x

						snake_case_   : int						=			area_under_curve_estimator(
						    __UpperCamelCase					, __UpperCamelCase					, __UpperCamelCase					, __UpperCamelCase    )
						snake_case_   : str						=			(max_value * max_value - min_value * min_value) / 2

						print("""******************"""    )
						print(F'Estimating area under y=x where x varies from {min_value} to {max_value}'    )
						print(F'Estimated value is {estimated_value}'    )
						print(F'Expected value is {expected_value}'    )
						print(F'Total error is {abs(estimated_value - expected_value    )}'    )
						print("""******************"""    )
def 	__lowerCAmelCase						(		__UpperCamelCase      :			int    ):


						'''simple docstring'''






						def function_to_integrate(__UpperCamelCase      :			float    ) -> float:
												return sqrt(4.0 - x * x    )

						snake_case_   : List[Any]						=			area_under_curve_estimator(
						    __UpperCamelCase					, __UpperCamelCase					, 0.0					, 2.0    )

						print("""******************"""    )
						print("""Estimating pi using area_under_curve_estimator"""    )
						print(F'Estimated value is {estimated_value}'    )
						print(F'Expected value is {pi}'    )
						print(F'Total error is {abs(estimated_value - pi    )}'    )
						print("""******************"""    )


if __name__ == "__main__":
					import doctest

					doctest.testmod()

