





from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union

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


if TYPE_CHECKING:
     from ...feature_extraction_utils import FeatureExtractionMixin
     from ...tokenization_utils_base import PreTrainedTokenizerBase
     from ...utils import TensorType

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

_snake_case  :    Any						    =  {
    'openai/whisper-base': 'https://huggingface.co/openai/whisper-base/resolve/main/config.json',
}

# fmt: off
_snake_case  :    str						    =  [
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 357, 366, 438, 532, 685,
    705, 796, 930, 1058, 1220, 1267, 1279, 1303, 1343, 1377,
    1391, 1635, 1782, 1875, 2162, 2361, 2488, 3467, 4008, 4211,
    4600, 4808, 5299, 5855, 6329, 7203, 9609, 9959, 10563, 10786,
    11420, 11709, 11907, 13163, 13697, 13700, 14808, 15306, 16410, 16791,
    17992, 19203, 19510, 20724, 22305, 22935, 27007, 30109, 30420, 33409,
    34949, 40283, 40493, 40549, 47282, 49146, 50257, 50359, 50360, 50361
]
_snake_case  :    Tuple						    =  [
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 359, 503, 522, 542, 873,
    893, 902, 918, 922, 931, 1350, 1853, 1982, 2460, 2627,
    3246, 3253, 3268, 3536, 3846, 3961, 4183, 4667, 6585, 6647,
    7273, 9061, 9383, 10428, 10929, 11938, 12033, 12331, 12562, 13793,
    14157, 14635, 15265, 15618, 16553, 16604, 18362, 18956, 20075, 21675,
    22520, 26130, 26161, 26435, 28279, 29464, 31650, 32302, 32470, 36865,
    42863, 47425, 49870, 50254, 50258, 50360, 50361, 50362
]



class 				_UpperCAmelCase    (    _UpperCamelCase    ):

  """simple docstring"""


  a_        = """whisper"""
  a_        = ["""past_key_values"""]
  a_        = {"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}






  def __init__(				self :		Optional[int]					,  lowerCAmelCase_ :		Any=5_1_8_6_5					,  lowerCAmelCase_ :		int=8_0					,  lowerCAmelCase_ :		Dict=6					,  lowerCAmelCase_ :		Union[str, Any]=4					,  lowerCAmelCase_ :		Dict=6					,  lowerCAmelCase_ :		Union[str, Any]=4					,  lowerCAmelCase_ :		Dict=1_5_3_6					,  lowerCAmelCase_ :		Optional[int]=1_5_3_6					,  lowerCAmelCase_ :		Optional[Any]=0.0					,  lowerCAmelCase_ :		Dict=0.0					,  lowerCAmelCase_ :		str=5_0_2_5_7					,  lowerCAmelCase_ :		List[Any]=True					,  lowerCAmelCase_ :		int=True					,  lowerCAmelCase_ :		Tuple="gelu"					,  lowerCAmelCase_ :		Tuple=2_5_6					,  lowerCAmelCase_ :		List[str]=0.0					,  lowerCAmelCase_ :		str=0.0					,  lowerCAmelCase_ :		List[str]=0.0					,  lowerCAmelCase_ :		Dict=0.02					,  lowerCAmelCase_ :		Optional[int]=False					,  lowerCAmelCase_ :		Union[str, Any]=1_5_0_0					,  lowerCAmelCase_ :		Any=4_4_8					,  lowerCAmelCase_ :		Optional[Any]=5_0_2_5_6					,  lowerCAmelCase_ :		int=5_0_2_5_6					,  lowerCAmelCase_ :		Optional[Any]=5_0_2_5_6					,  lowerCAmelCase_ :		str=None					,  lowerCAmelCase_ :		List[str]=[2_2_0, 5_0_2_5_6]					,  lowerCAmelCase_ :		str=False					,  lowerCAmelCase_ :		int=2_5_6					,  lowerCAmelCase_ :		str=False					,  lowerCAmelCase_ :		Optional[Any]=0.05					,  lowerCAmelCase_ :		Tuple=1_0					,  lowerCAmelCase_ :		Dict=2					,  lowerCAmelCase_ :		int=0.0					,  lowerCAmelCase_ :		Optional[int]=1_0					,  lowerCAmelCase_ :		List[str]=0					,  lowerCAmelCase_ :		Dict=7					,  **lowerCAmelCase_ :		List[str]					,  )							->						Tuple:
     __lowerCAmelCase								=	vocab_size
     __lowerCAmelCase								=	num_mel_bins
     __lowerCAmelCase								=	d_model
     __lowerCAmelCase								=	encoder_layers
     __lowerCAmelCase								=	encoder_attention_heads
     __lowerCAmelCase								=	decoder_layers
     __lowerCAmelCase								=	decoder_attention_heads
     __lowerCAmelCase								=	decoder_ffn_dim
     __lowerCAmelCase								=	encoder_ffn_dim
     __lowerCAmelCase								=	dropout
     __lowerCAmelCase								=	attention_dropout
     __lowerCAmelCase								=	activation_dropout
     __lowerCAmelCase								=	activation_function
     __lowerCAmelCase								=	init_std
     __lowerCAmelCase								=	encoder_layerdrop
     __lowerCAmelCase								=	decoder_layerdrop
     __lowerCAmelCase								=	use_cache
     __lowerCAmelCase								=	encoder_layers
     __lowerCAmelCase								=	scale_embedding  # scale factor will be sqrt(d_model) if True
     __lowerCAmelCase								=	max_source_positions
     __lowerCAmelCase								=	max_target_positions

     # Audio Classification-specific parameters. Feel free to ignore for other classes.
     __lowerCAmelCase								=	classifier_proj_size
     __lowerCAmelCase								=	use_weighted_layer_sum

     # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
     __lowerCAmelCase								=	apply_spec_augment
     __lowerCAmelCase								=	mask_time_prob
     __lowerCAmelCase								=	mask_time_length
     __lowerCAmelCase								=	mask_time_min_masks
     __lowerCAmelCase								=	mask_feature_prob
     __lowerCAmelCase								=	mask_feature_length
     __lowerCAmelCase								=	mask_feature_min_masks

     __lowerCAmelCase								=	median_filter_width

     super().__init__(
         pad_token_id=lowerCAmelCase_					,  bos_token_id=lowerCAmelCase_					,  eos_token_id=lowerCAmelCase_					,  is_encoder_decoder=lowerCAmelCase_					,  decoder_start_token_id=lowerCAmelCase_					,  suppress_tokens=lowerCAmelCase_					,  begin_suppress_tokens=lowerCAmelCase_					,  **lowerCAmelCase_					,  )





class 				_UpperCAmelCase    (    _UpperCamelCase    ):

  """simple docstring"""


  @property
  def 				lowercase		(				self :		Tuple     )							->						Mapping[str, Mapping[int, str]]:
     __lowerCAmelCase								=	OrderedDict(
         [
             ('input_features', {0: 'batch', 1: 'feature_size', 2: 'encoder_sequence'}),
         ]     )
     if self.use_past:
        __lowerCAmelCase								=	{0: 'batch'}
     else:
        __lowerCAmelCase								=	{0: 'batch', 1: 'decoder_sequence'}

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

     return common_inputs






  def 				lowercase		(				self :		int					,  lowerCAmelCase_ :		Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]					,  lowerCAmelCase_ :		int = -1					,  lowerCAmelCase_ :		int = -1					,  lowerCAmelCase_ :		bool = False					,  lowerCAmelCase_ :		Optional["TensorType"] = None					,  lowerCAmelCase_ :		int = 2_2_0_5_0					,  lowerCAmelCase_ :		float = 5.0					,  lowerCAmelCase_ :		int = 2_2_0					,  )							->						Mapping[str, Any]:
     __lowerCAmelCase								=	OrderedDict()
     __lowerCAmelCase								=	OnnxConfig.generate_dummy_inputs(
         self					,  preprocessor=preprocessor.feature_extractor					,  batch_size=lowerCAmelCase_					,  framework=lowerCAmelCase_					,  sampling_rate=lowerCAmelCase_					,  time_duration=lowerCAmelCase_					,  frequency=lowerCAmelCase_					,  )
     __lowerCAmelCase								=	encoder_inputs['input_features'].shape[2]
     __lowerCAmelCase								=	encoder_sequence_length // 2 if self.use_past else seq_length

     __lowerCAmelCase								=	super().generate_dummy_inputs(
         preprocessor.tokenizer					,  lowerCAmelCase_					,  lowerCAmelCase_					,  lowerCAmelCase_					,  lowerCAmelCase_     )

     __lowerCAmelCase								=	encoder_inputs.pop('input_features'     )
     __lowerCAmelCase								=	decoder_inputs.pop('decoder_input_ids'     )

     if "past_key_values" in decoder_inputs:
        __lowerCAmelCase								=	decoder_inputs.pop('past_key_values'     )

     return dummy_inputs






  @property
  def 				lowercase		(				self :		Optional[int]     )							->						float:
     return 1e-3








def   a_    ( lowerCAmelCase_      :			str,	lowerCAmelCase_      :			int	):
   return [sentence[i : i + ngram_size] for i in range(len(lowerCAmelCase_	) - ngram_size + 1	)]


if __name__ == "__main__":
     from doctest import testmod

     testmod()

