

"""simple docstring"""




from collections import OrderedDict
from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


__A  :					List[Any]												=	logging.get_logger(__name__)

__A  :					Union[str, Any]												=	{
    'mnaylor/mega-base-wikitext': 'https://huggingface.co/mnaylor/mega-base-wikitext/resolve/main/config.json',
}





class     __UpperCamelCase				(     _A		):
		SCREAMING_SNAKE_CASE              =					"mega"


		def __init__(self				:	List[Any]  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=3_0_5_2_2  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]=1_2_8  ,  __SCREAMING_SNAKE_CASE				:	Any=4  ,  __SCREAMING_SNAKE_CASE				:	Dict=2_5_6  ,  __SCREAMING_SNAKE_CASE				:	str=1_6  ,  __SCREAMING_SNAKE_CASE				:	int=True  ,  __SCREAMING_SNAKE_CASE				:	Tuple=6_4  ,  __SCREAMING_SNAKE_CASE				:	Any=False  ,  __SCREAMING_SNAKE_CASE				:	int=-1  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]=None  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=True  ,  __SCREAMING_SNAKE_CASE				:	Dict="scalenorm"  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]=True  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]="silu"  ,  __SCREAMING_SNAKE_CASE				:	int="softmax"  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]=0.1  ,  __SCREAMING_SNAKE_CASE				:	str=0.1  ,  __SCREAMING_SNAKE_CASE				:	Tuple=0.1  ,  __SCREAMING_SNAKE_CASE				:	List[str]=False  ,  __SCREAMING_SNAKE_CASE				:	Optional[int]=True  ,  __SCREAMING_SNAKE_CASE				:	int=2_5_6  ,  __SCREAMING_SNAKE_CASE				:	Tuple=True  ,  __SCREAMING_SNAKE_CASE				:	Dict=0.1  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=2_0_4_8  ,  __SCREAMING_SNAKE_CASE				:	Dict=False  ,  __SCREAMING_SNAKE_CASE				:	str=2  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]=0.0_2  ,  __SCREAMING_SNAKE_CASE				:	Any=0.2  ,  __SCREAMING_SNAKE_CASE				:	int=0.0_2  ,  __SCREAMING_SNAKE_CASE				:	str=1.0  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=1  ,  __SCREAMING_SNAKE_CASE				:	Tuple=0  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=2  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]="rotary"  ,  __SCREAMING_SNAKE_CASE				:	Optional[int]=None  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=True  ,  __SCREAMING_SNAKE_CASE				:	Tuple=True  ,  **__SCREAMING_SNAKE_CASE				:	List[str]  ,  ):
							super().__init__(pad_token_id=__SCREAMING_SNAKE_CASE  ,  bos_token_id=__SCREAMING_SNAKE_CASE  ,  eos_token_id=__SCREAMING_SNAKE_CASE  ,  **__SCREAMING_SNAKE_CASE)

							A    =      vocab_size
							A    =      hidden_size
							A    =      num_hidden_layers
							A    =      activation
							A    =      attention_activation
							A    =      intermediate_size
							A    =      ema_projection_size
							A    =      bidirectional
							A    =      shared_representation_size
							A    =      use_chunking
							A    =      chunk_size
							A    =      truncation
							A    =      normalize_before_mega
							A    =      normalization_type
							A    =      norm_affine
							A    =      dropout_prob
							A    =      hidden_dropout_prob
							A    =      attention_probs_dropout_prob
							A    =      use_feature_dropout
							A    =      use_normalized_ffn
							A    =      nffn_hidden_size
							A    =      normalize_before_ffn
							A    =      nffn_activation_dropout_prob
							A    =      max_positions
							A    =      add_token_type_embeddings
							A    =      type_vocab_size
							A    =      initializer_range
							A    =      ema_delta_alpha_range
							A    =      ema_beta_range
							A    =      ema_gamma_omega_range
							A    =      relative_positional_bias
							A    =      use_cache
							A    =      classifier_dropout
							A    =      add_lm_hidden_dense_layer
							A    =      1  # not used but required by Hugging Face





class     __UpperCamelCase				(     _A		):


		@property
		def       SCREAMING_SNAKE_CASE__     (self				:	int):
							if self.task == "multiple-choice":
												A    =      {0: "batch", 1: "choice", 2: "sequence"}
							else:
												A    =      {0: "batch", 1: "sequence"}
							return OrderedDict(
							    [
							        ("input_ids", dynamic_axis),
							        ("attention_mask", dynamic_axis),
							    ])








"""simple docstring"""




from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxSeqaSeqConfigWithPast
from ...utils import logging


__A  :					List[str]												=	logging.get_logger(__name__)





class     __UpperCamelCase				(     _A		):
		SCREAMING_SNAKE_CASE              =					"mt5"
		SCREAMING_SNAKE_CASE              =					["past_key_values"]


		def __init__(self				:	Optional[Any]  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]=2_5_0_1_1_2  ,  __SCREAMING_SNAKE_CASE				:	int=5_1_2  ,  __SCREAMING_SNAKE_CASE				:	Tuple=6_4  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]=1_0_2_4  ,  __SCREAMING_SNAKE_CASE				:	Optional[int]=8  ,  __SCREAMING_SNAKE_CASE				:	Any=None  ,  __SCREAMING_SNAKE_CASE				:	Tuple=6  ,  __SCREAMING_SNAKE_CASE				:	int=3_2  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=1_2_8  ,  __SCREAMING_SNAKE_CASE				:	Tuple=0.1  ,  __SCREAMING_SNAKE_CASE				:	Tuple=1E-6  ,  __SCREAMING_SNAKE_CASE				:	List[Any]=1.0  ,  __SCREAMING_SNAKE_CASE				:	Optional[int]="gated-gelu"  ,  __SCREAMING_SNAKE_CASE				:	List[str]=True  ,  __SCREAMING_SNAKE_CASE				:	str=True  ,  __SCREAMING_SNAKE_CASE				:	int="T5Tokenizer"  ,  __SCREAMING_SNAKE_CASE				:	Optional[int]=False  ,  __SCREAMING_SNAKE_CASE				:	Optional[Any]=0  ,  __SCREAMING_SNAKE_CASE				:	Tuple=1  ,  __SCREAMING_SNAKE_CASE				:	List[str]=0  ,  **__SCREAMING_SNAKE_CASE				:	str  ,  ):
							super().__init__(
							    is_encoder_decoder=__SCREAMING_SNAKE_CASE  ,  tokenizer_class=__SCREAMING_SNAKE_CASE  ,  tie_word_embeddings=__SCREAMING_SNAKE_CASE  ,  pad_token_id=__SCREAMING_SNAKE_CASE  ,  eos_token_id=__SCREAMING_SNAKE_CASE  ,  decoder_start_token_id=__SCREAMING_SNAKE_CASE  ,  **__SCREAMING_SNAKE_CASE  ,  )
							A    =      vocab_size
							A    =      d_model
							A    =      d_kv
							A    =      d_ff
							A    =      num_layers
							A    =      (
							    num_decoder_layers if num_decoder_layers is not None else self.num_layers
							)  # default = symmetry
							A    =      num_heads
							A    =      relative_attention_num_buckets
							A    =      relative_attention_max_distance
							A    =      dropout_rate
							A    =      layer_norm_epsilon
							A    =      initializer_factor
							A    =      feed_forward_proj
							A    =      use_cache

							A    =      self.feed_forward_proj.split("-")
							A    =      act_info[-1]
							A    =      act_info[0] == "gated"

							if len(__SCREAMING_SNAKE_CASE) > 1 and act_info[0] != "gated" or len(__SCREAMING_SNAKE_CASE) > 2:
												raise ValueError(
												    F"""`feed_forward_proj`: {feed_forward_proj} is not a valid activation function of the dense layer."""
												    "Please make sure `feed_forward_proj` is of the format `gated-{ACT_FN}` or `{ACT_FN}`, e.g. "
												    "'gated-gelu' or 'relu'")

							# for backwards compatibility
							if feed_forward_proj == "gated-gelu":
												A    =      "gelu_new"


		@property
		def       SCREAMING_SNAKE_CASE__     (self				:	List[Any]):
							return self.d_model


		@property
		def       SCREAMING_SNAKE_CASE__     (self				:	Optional[int]):
							return self.num_heads


		@property
		def       SCREAMING_SNAKE_CASE__     (self				:	Optional[int]):
							return self.num_layers





class     __UpperCamelCase				(     _A		):


		@property
		# Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.inputs
		def       SCREAMING_SNAKE_CASE__     (self				:	int):
							A    =      {
							    "input_ids": {0: "batch", 1: "encoder_sequence"},
							    "attention_mask": {0: "batch", 1: "encoder_sequence"},
							}
							if self.use_past:
												A    =      "past_encoder_sequence + sequence"
												A    =      {0: "batch"}
												A    =      {0: "batch", 1: "past_decoder_sequence + sequence"}
							else:
												A    =      {0: "batch", 1: "decoder_sequence"}
												A    =      {0: "batch", 1: "decoder_sequence"}

							if self.use_past:
												self.fill_with_past_key_values_(__SCREAMING_SNAKE_CASE  ,  direction="inputs")

							return common_inputs


		@property
		# Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.default_onnx_opset
		def       SCREAMING_SNAKE_CASE__     (self				:	Union[str, Any]):
							return 1_3


		@property
		def       SCREAMING_SNAKE_CASE__     (self				:	int):
							return 5E-4





