




'''simple docstring'''



from typing import Mapping

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


lowerCamelCase_		       =						logging.get_logger(__name__)







class 		lowercase_    ( a__   ):


   """simple docstring"""

   lowerCamelCase_				  =						'''mt5'''
   lowerCamelCase_				  =						['''past_key_values''']



   def __init__(    self					:	Any  ,      __lowerCamelCase					:	List[str]=2_5_0_1_1_2  ,      __lowerCamelCase					:	int=5_1_2  ,      __lowerCamelCase					:	int=6_4  ,      __lowerCamelCase					:	str=1_0_2_4  ,      __lowerCamelCase					:	Any=8  ,      __lowerCamelCase					:	Dict=None  ,      __lowerCamelCase					:	str=6  ,      __lowerCamelCase					:	Any=3_2  ,      __lowerCamelCase					:	List[str]=1_2_8  ,      __lowerCamelCase					:	Dict=0.1  ,      __lowerCamelCase					:	Dict=1e-6  ,      __lowerCamelCase					:	Optional[int]=1.0  ,      __lowerCamelCase					:	Union[str, Any]="gated-gelu"  ,      __lowerCamelCase					:	Optional[int]=True  ,      __lowerCamelCase					:	int=True  ,      __lowerCamelCase					:	Optional[Any]="T5Tokenizer"  ,      __lowerCamelCase					:	Any=False  ,      __lowerCamelCase					:	Optional[Any]=0  ,      __lowerCamelCase					:	List[Any]=1  ,      __lowerCamelCase					:	Dict=0  ,      **__lowerCamelCase					:	Any  ,      ):

      """simple docstring"""
      super().__init__(
          is_encoder_decoder=_snake_case  ,      tokenizer_class=_snake_case  ,      tie_word_embeddings=_snake_case  ,      pad_token_id=_snake_case  ,      eos_token_id=_snake_case  ,      decoder_start_token_id=_snake_case  ,      **_snake_case  ,      )
      _SCREAMING_SNAKE_CASE       =      vocab_size
      _SCREAMING_SNAKE_CASE       =      d_model
      _SCREAMING_SNAKE_CASE       =      d_kv
      _SCREAMING_SNAKE_CASE       =      d_ff
      _SCREAMING_SNAKE_CASE       =      num_layers
      _SCREAMING_SNAKE_CASE       =      (
          num_decoder_layers if num_decoder_layers is not None else self.num_layers
      )  # default = symmetry
      _SCREAMING_SNAKE_CASE       =      num_heads
      _SCREAMING_SNAKE_CASE       =      relative_attention_num_buckets
      _SCREAMING_SNAKE_CASE       =      relative_attention_max_distance
      _SCREAMING_SNAKE_CASE       =      dropout_rate
      _SCREAMING_SNAKE_CASE       =      layer_norm_epsilon
      _SCREAMING_SNAKE_CASE       =      initializer_factor
      _SCREAMING_SNAKE_CASE       =      feed_forward_proj
      _SCREAMING_SNAKE_CASE       =      use_cache

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

      if len(_snake_case    ) > 1 and act_info[0] != "gated" or len(_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":
         _SCREAMING_SNAKE_CASE       =      "gelu_new"



   @property
   def 							lowerCAmelCase_			(    self					:	List[Any]    ):

      """simple docstring"""
      return self.d_model



   @property
   def 							lowerCAmelCase_			(    self					:	Dict    ):

      """simple docstring"""
      return self.num_heads



   @property
   def 							lowerCAmelCase_			(    self					:	List[Any]    ):

      """simple docstring"""
      return self.num_layers







class 		lowercase_    ( a__   ):


   """simple docstring"""

   @property
   # Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.inputs
   def 							lowerCAmelCase_			(    self					:	List[str]    ):

      """simple docstring"""
      _SCREAMING_SNAKE_CASE       =      {
          "input_ids": {0: "batch", 1: "encoder_sequence"},
          "attention_mask": {0: "batch", 1: "encoder_sequence"},
      }
      if self.use_past:
         _SCREAMING_SNAKE_CASE       =      "past_encoder_sequence + sequence"
         _SCREAMING_SNAKE_CASE       =      {0: "batch"}
         _SCREAMING_SNAKE_CASE       =      {0: "batch", 1: "past_decoder_sequence + sequence"}
      else:
         _SCREAMING_SNAKE_CASE       =      {0: "batch", 1: "decoder_sequence"}
         _SCREAMING_SNAKE_CASE       =      {0: "batch", 1: "decoder_sequence"}

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

      return common_inputs



   @property
   # Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.default_onnx_opset
   def 							lowerCAmelCase_			(    self					:	List[Any]    ):

      """simple docstring"""
      return 1_3



   @property
   def 							lowerCAmelCase_			(    self					:	Any    ):

      """simple docstring"""
      return 5e-4








"""simple docstring"""
import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin







class 	a				(					a__   ):
 snake_case__    	=    '''AutoFeatureExtractor'''
 snake_case__    	=    '''Speech2Text2Tokenizer'''



 def __init__(			self							,    _snake_case							,    _snake_case			):







  """simple docstring"""






  super().__init__(_snake_case							,    _snake_case			)
  lowerCAmelCase  							=      self.feature_extractor
  lowerCAmelCase  							=      False



 def __call__(			self							,    *_snake_case							,    **_snake_case			):







  """simple docstring"""






  if self._in_target_context_manager:
   return self.current_processor(*_snake_case							,    **_snake_case			)

  if "raw_speech" in kwargs:
   warnings.warn('Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'			)
   lowerCAmelCase  							=      kwargs.pop('raw_speech'			)
  else:
   lowerCAmelCase  							=      kwargs.pop('audio'							,    _snake_case			)
  lowerCAmelCase  							=      kwargs.pop('sampling_rate'							,    _snake_case			)
  lowerCAmelCase  							=      kwargs.pop('text'							,    _snake_case			)
  if len(_snake_case			) > 0:
   lowerCAmelCase  							=      args[0]
   lowerCAmelCase  							=      args[1:]

  if audio is None and text is None:
   raise ValueError('You need to specify either an `audio` or `text` input to process.'			)

  if audio is not None:
   lowerCAmelCase  							=      self.feature_extractor(_snake_case							,    *_snake_case							,    sampling_rate=_snake_case							,    **_snake_case			)
  if text is not None:
   lowerCAmelCase  							=      self.tokenizer(_snake_case							,    **_snake_case			)

  if text is None:
   return inputs
  elif audio is None:
   return encodings
  else:
   lowerCAmelCase  							=      encodings['input_ids']
   return inputs



 def 					UpperCamelCase__   (			self							,    *_snake_case							,    **_snake_case			):







  """simple docstring"""






  return self.tokenizer.batch_decode(*_snake_case							,    **_snake_case			)



 def 					UpperCamelCase__   (			self							,    *_snake_case							,    **_snake_case			):







  """simple docstring"""






  return self.tokenizer.decode(*_snake_case							,    **_snake_case			)



 @contextmanager
 def 					UpperCamelCase__   (			self			):







  """simple docstring"""






  warnings.warn(
      '`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '
      'labels by using the argument `text` of the regular `__call__` method (either in the same call as '
      'your audio inputs, or in a separate call.'			)
  lowerCAmelCase  							=      True
  lowerCAmelCase  							=      self.tokenizer
  yield
  lowerCAmelCase  							=      self.feature_extractor
  lowerCAmelCase  							=      False





