

from typing import Mapping

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


_a	 =     logging.get_logger(__name__)






class 							A_				(	snake_case__      ):
     _lowercase    :  Any          =			'mt5'
     _lowercase    :  List[str]          =			['past_key_values']


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

      __lowerCAmelCase:     Dict     			=   self.feed_forward_proj.split('-'      )
      __lowerCAmelCase:     Any     			=   act_info[-1]
      __lowerCAmelCase:     int     			=   act_info[0] == 'gated'

      if len(UpperCAmelCase      ) > 1 and act_info[0] != "gated" or len(UpperCAmelCase      ) > 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":
       __lowerCAmelCase:     str     			=   'gelu_new'


     @property
     def 						UpperCAmelCase						(							self    :	int      )							->			Tuple:
      return self.d_model


     @property
     def 						UpperCAmelCase						(							self    :	int      )							->			int:
      return self.num_heads


     @property
     def 						UpperCAmelCase						(							self    :	Optional[Any]      )							->			List[str]:
      return self.num_layers







class 							A_				(	snake_case__      ):


     @property
     # Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.inputs
     def 						UpperCAmelCase						(							self    :	Union[str, Any]      )							->			Mapping[str, Mapping[int, str]]:
      __lowerCAmelCase:     Dict     			=   {
          'input_ids': {0: 'batch', 1: 'encoder_sequence'},
          'attention_mask': {0: 'batch', 1: 'encoder_sequence'},
      }
      if self.use_past:
       __lowerCAmelCase:     Tuple     			=   'past_encoder_sequence + sequence'
       __lowerCAmelCase:     Optional[Any]     			=   {0: 'batch'}
       __lowerCAmelCase:     Tuple     			=   {0: 'batch', 1: 'past_decoder_sequence + sequence'}
      else:
       __lowerCAmelCase:     List[str]     			=   {0: 'batch', 1: 'decoder_sequence'}
       __lowerCAmelCase:     int     			=   {0: 'batch', 1: 'decoder_sequence'}

      if self.use_past:
       self.fill_with_past_key_values_(UpperCAmelCase    ,						direction='inputs'      )

      return common_inputs


     @property
     # Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.default_onnx_opset
     def 						UpperCAmelCase						(							self    :	int      )							->			int:
      return 1_3


     @property
     def 						UpperCAmelCase						(							self    :	str      )							->			float:
      return 5E-4








from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_keras_nlp_available,
    is_tensorflow_text_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


_a	 =     {
    '''configuration_gpt2''': ['''GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPT2Config''', '''GPT2OnnxConfig'''],
    '''tokenization_gpt2''': ['''GPT2Tokenizer'''],
}

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _a	 =     ['''GPT2TokenizerFast''']

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _a	 =     [
      '''GPT2_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''GPT2DoubleHeadsModel''',
      '''GPT2ForQuestionAnswering''',
      '''GPT2ForSequenceClassification''',
      '''GPT2ForTokenClassification''',
      '''GPT2LMHeadModel''',
      '''GPT2Model''',
      '''GPT2PreTrainedModel''',
      '''load_tf_weights_in_gpt2''',
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _a	 =     [
      '''TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''TFGPT2DoubleHeadsModel''',
      '''TFGPT2ForSequenceClassification''',
      '''TFGPT2LMHeadModel''',
      '''TFGPT2MainLayer''',
      '''TFGPT2Model''',
      '''TFGPT2PreTrainedModel''',
  ]

try:
  if not is_keras_nlp_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _a	 =     ['''TFGPT2Tokenizer''']

try:
  if not is_flax_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _a	 =     ['''FlaxGPT2LMHeadModel''', '''FlaxGPT2Model''', '''FlaxGPT2PreTrainedModel''']

if TYPE_CHECKING:
  from .configuration_gpta import GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTaConfig, GPTaOnnxConfig
  from .tokenization_gpta import GPTaTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_gpta_fast import GPTaTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_gpta import (
        GPT2_PRETRAINED_MODEL_ARCHIVE_LIST,
        GPTaDoubleHeadsModel,
        GPTaForQuestionAnswering,
        GPTaForSequenceClassification,
        GPTaForTokenClassification,
        GPTaLMHeadModel,
        GPTaModel,
        GPTaPreTrainedModel,
        load_tf_weights_in_gpta,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_gpta import (
        TF_GPT2_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFGPTaDoubleHeadsModel,
        TFGPTaForSequenceClassification,
        TFGPTaLMHeadModel,
        TFGPTaMainLayer,
        TFGPTaModel,
        TFGPTaPreTrainedModel,
    )

  try:
    if not is_keras_nlp_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_gpta_tf import TFGPTaTokenizer

  try:
    if not is_flax_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_flax_gpta import FlaxGPTaLMHeadModel, FlaxGPTaModel, FlaxGPTaPreTrainedModel

else:
  import sys

  _a	 =     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





