




'''simple docstring'''


from collections import OrderedDict
from typing import Mapping

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


UpperCamelCase			     =					logging.get_logger(__name__)

UpperCamelCase			     =					{
    '''mnaylor/mega-base-wikitext''': '''https://huggingface.co/mnaylor/mega-base-wikitext/resolve/main/config.json''',
}






class 						lowerCAmelCase_	(       UpperCAmelCase_							):







  '''simple docstring'''

  UpperCamelCase_			:      Tuple										=				"""mega"""



  def __init__( self				:							Any					,  SCREAMING_SNAKE_CASE_				:							int=3_05_22					,  SCREAMING_SNAKE_CASE_				:							Optional[Any]=1_28					,  SCREAMING_SNAKE_CASE_				:							str=4					,  SCREAMING_SNAKE_CASE_				:							Tuple=2_56					,  SCREAMING_SNAKE_CASE_				:							int=16					,  SCREAMING_SNAKE_CASE_				:							Dict=True					,  SCREAMING_SNAKE_CASE_				:							Optional[int]=64					,  SCREAMING_SNAKE_CASE_				:							Union[str, Any]=False					,  SCREAMING_SNAKE_CASE_				:							Any=-1					,  SCREAMING_SNAKE_CASE_				:							Union[str, Any]=None					,  SCREAMING_SNAKE_CASE_				:							Any=True					,  SCREAMING_SNAKE_CASE_				:							int="scalenorm"					,  SCREAMING_SNAKE_CASE_				:							Dict=True					,  SCREAMING_SNAKE_CASE_				:							Dict="silu"					,  SCREAMING_SNAKE_CASE_				:							str="softmax"					,  SCREAMING_SNAKE_CASE_				:							Dict=0.1					,  SCREAMING_SNAKE_CASE_				:							List[Any]=0.1					,  SCREAMING_SNAKE_CASE_				:							Optional[int]=0.1					,  SCREAMING_SNAKE_CASE_				:							Dict=False					,  SCREAMING_SNAKE_CASE_				:							str=True					,  SCREAMING_SNAKE_CASE_				:							Optional[int]=2_56					,  SCREAMING_SNAKE_CASE_				:							str=True					,  SCREAMING_SNAKE_CASE_				:							Dict=0.1					,  SCREAMING_SNAKE_CASE_				:							List[Any]=20_48					,  SCREAMING_SNAKE_CASE_				:							Union[str, Any]=False					,  SCREAMING_SNAKE_CASE_				:							List[Any]=2					,  SCREAMING_SNAKE_CASE_				:							Any=0.02					,  SCREAMING_SNAKE_CASE_				:							str=0.2					,  SCREAMING_SNAKE_CASE_				:							Union[str, Any]=0.02					,  SCREAMING_SNAKE_CASE_				:							List[str]=1.0					,  SCREAMING_SNAKE_CASE_				:							int=1					,  SCREAMING_SNAKE_CASE_				:							Dict=0					,  SCREAMING_SNAKE_CASE_				:							Union[str, Any]=2					,  SCREAMING_SNAKE_CASE_				:							int="rotary"					,  SCREAMING_SNAKE_CASE_				:							int=None					,  SCREAMING_SNAKE_CASE_				:							Dict=True					,  SCREAMING_SNAKE_CASE_				:							Optional[Any]=True					,  **SCREAMING_SNAKE_CASE_				:							List[str]					,  )			->		List[str]:







       '''simple docstring'''



       super().__init__(pad_token_id=SCREAMING_SNAKE_CASE_					,  bos_token_id=SCREAMING_SNAKE_CASE_					,  eos_token_id=SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_	)

       A:		int          =		vocab_size
       A:		int          =		hidden_size
       A:		Tuple          =		num_hidden_layers
       A:		List[Any]          =		activation
       A:		List[Any]          =		attention_activation
       A:		Union[str, Any]          =		intermediate_size
       A:		str          =		ema_projection_size
       A:		Optional[int]          =		bidirectional
       A:		str          =		shared_representation_size
       A:		int          =		use_chunking
       A:		List[Any]          =		chunk_size
       A:		Tuple          =		truncation
       A:		List[str]          =		normalize_before_mega
       A:		str          =		normalization_type
       A:		Optional[int]          =		norm_affine
       A:		Optional[int]          =		dropout_prob
       A:		List[str]          =		hidden_dropout_prob
       A:		List[Any]          =		attention_probs_dropout_prob
       A:		List[Any]          =		use_feature_dropout
       A:		Tuple          =		use_normalized_ffn
       A:		Dict          =		nffn_hidden_size
       A:		List[str]          =		normalize_before_ffn
       A:		str          =		nffn_activation_dropout_prob
       A:		Dict          =		max_positions
       A:		int          =		add_token_type_embeddings
       A:		Optional[int]          =		type_vocab_size
       A:		List[str]          =		initializer_range
       A:		Dict          =		ema_delta_alpha_range
       A:		Optional[int]          =		ema_beta_range
       A:		Union[str, Any]          =		ema_gamma_omega_range
       A:		str          =		relative_positional_bias
       A:		Union[str, Any]          =		use_cache
       A:		Union[str, Any]          =		classifier_dropout
       A:		Union[str, Any]          =		add_lm_hidden_dense_layer
       A:		str          =		1  # not used but required by Hugging Face






class 						lowerCAmelCase_	(       UpperCAmelCase_							):







  '''simple docstring'''

  @property
  def 					_snake_case     ( self				:							int	)			->		Mapping[str, Mapping[int, str]]:







       '''simple docstring'''



       if self.task == "multiple-choice":
            A:		Optional[Any]          =		{0: '''batch''', 1: '''choice''', 2: '''sequence'''}
       else:
            A:		List[str]          =		{0: '''batch''', 1: '''sequence'''}
       return OrderedDict(
           [
               ('''input_ids''', dynamic_axis),
               ('''attention_mask''', dynamic_axis),
           ]	)












'''simple docstring'''


import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin






class 						lowerCAmelCase_	(       UpperCAmelCase_							):







  '''simple docstring'''

  UpperCamelCase_			:      Optional[int]										=				"""AutoFeatureExtractor"""
  UpperCamelCase_			:      List[Any]										=				"""Speech2Text2Tokenizer"""



  def __init__( self				:							str					,  SCREAMING_SNAKE_CASE_				:							str					,  SCREAMING_SNAKE_CASE_				:							int	)			->		Any:







       '''simple docstring'''



       super().__init__(SCREAMING_SNAKE_CASE_					,  SCREAMING_SNAKE_CASE_	)
       A:		Union[str, Any]          =		self.feature_extractor
       A:		Dict          =		False



  def __call__( self				:							Any					,  *SCREAMING_SNAKE_CASE_				:							Any					,  **SCREAMING_SNAKE_CASE_				:							Optional[int]	)			->		Optional[Any]:







       '''simple docstring'''



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

       if "raw_speech" in kwargs:
            warnings.warn('''Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'''	)
            A:		List[str]          =		kwargs.pop('''raw_speech'''	)
       else:
            A:		Any          =		kwargs.pop('''audio'''					,  SCREAMING_SNAKE_CASE_	)
       A:		List[Any]          =		kwargs.pop('''sampling_rate'''					,  SCREAMING_SNAKE_CASE_	)
       A:		Optional[int]          =		kwargs.pop('''text'''					,  SCREAMING_SNAKE_CASE_	)
       if len(SCREAMING_SNAKE_CASE_	) > 0:
            A:		str          =		args[0]
            A:		Tuple          =		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:
            A:		Tuple          =		self.feature_extractor(SCREAMING_SNAKE_CASE_					,  *SCREAMING_SNAKE_CASE_					,  sampling_rate=SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_	)
       if text is not None:
            A:		List[Any]          =		self.tokenizer(SCREAMING_SNAKE_CASE_					,  **SCREAMING_SNAKE_CASE_	)

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



  def 					_snake_case     ( self				:							Tuple					,  *SCREAMING_SNAKE_CASE_				:							int					,  **SCREAMING_SNAKE_CASE_				:							Union[str, Any]	)			->		str:







       '''simple docstring'''



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



  def 					_snake_case     ( self				:							Optional[int]					,  *SCREAMING_SNAKE_CASE_				:							str					,  **SCREAMING_SNAKE_CASE_				:							int	)			->		Union[str, Any]:







       '''simple docstring'''



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




  @contextmanager
  def 					_snake_case     ( self				:							str	)			->		int:







       '''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.'''	)
       A:		List[Any]          =		True
       A:		List[str]          =		self.tokenizer
       yield
       A:		List[Any]          =		self.feature_extractor
       A:		int          =		False






