

'''simple docstring'''

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

A_       						=							logging.get_logger(__name__)

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

# fmt: off
A_       						=							[
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 3_57, 3_66, 4_38, 5_32, 6_85,
    7_05, 7_96, 9_30, 10_58, 12_20, 12_67, 12_79, 13_03, 13_43, 13_77,
    13_91, 16_35, 17_82, 18_75, 21_62, 23_61, 24_88, 34_67, 40_08, 42_11,
    46_00, 48_08, 52_99, 58_55, 63_29, 72_03, 96_09, 99_59, 1_05_63, 1_07_86,
    1_14_20, 1_17_09, 1_19_07, 1_31_63, 1_36_97, 1_37_00, 1_48_08, 1_53_06, 1_64_10, 1_67_91,
    1_79_92, 1_92_03, 1_95_10, 2_07_24, 2_23_05, 2_29_35, 2_70_07, 3_01_09, 3_04_20, 3_34_09,
    3_49_49, 4_02_83, 4_04_93, 4_05_49, 4_72_82, 4_91_46, 5_02_57, 5_03_59, 5_03_60, 5_03_61
]
A_       						=							[
    1, 2, 7, 8, 9, 10, 14, 25,
    26, 27, 28, 29, 31, 58, 59, 60, 61, 62,
    63, 90, 91, 92, 93, 3_59, 5_03, 5_22, 5_42, 8_73,
    8_93, 9_02, 9_18, 9_22, 9_31, 13_50, 18_53, 19_82, 24_60, 26_27,
    32_46, 32_53, 32_68, 35_36, 38_46, 39_61, 41_83, 46_67, 65_85, 66_47,
    72_73, 90_61, 93_83, 1_04_28, 1_09_29, 1_19_38, 1_20_33, 1_23_31, 1_25_62, 1_37_93,
    1_41_57, 1_46_35, 1_52_65, 1_56_18, 1_65_53, 1_66_04, 1_83_62, 1_89_56, 2_00_75, 2_16_75,
    2_25_20, 2_61_30, 2_61_61, 2_64_35, 2_82_79, 2_94_64, 3_16_50, 3_23_02, 3_24_70, 3_68_65,
    4_28_63, 4_74_25, 4_98_70, 5_02_54, 5_02_58, 5_03_60, 5_03_61, 5_03_62
]





class 							_snake_case (       __a						):
   _A       :     List[str]       =					'''whisper'''
   _A       :     str       =					['''past_key_values''']
   _A       :     Tuple       =					{'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}
   def __init__( self			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      Optional[Any]=51_865     ,SCREAMING_SNAKE_CASE__			:      List[str]=80     ,SCREAMING_SNAKE_CASE__			:      int=6     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]=4     ,SCREAMING_SNAKE_CASE__			:      Tuple=6     ,SCREAMING_SNAKE_CASE__			:      Any=4     ,SCREAMING_SNAKE_CASE__			:      List[Any]=1_536     ,SCREAMING_SNAKE_CASE__			:      List[Any]=1_536     ,SCREAMING_SNAKE_CASE__			:      List[str]=0.0     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]=0.0     ,SCREAMING_SNAKE_CASE__			:      Optional[Any]=50_257     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]=True     ,SCREAMING_SNAKE_CASE__			:      Optional[int]=True     ,SCREAMING_SNAKE_CASE__			:      List[str]="gelu"     ,SCREAMING_SNAKE_CASE__			:      str=256     ,SCREAMING_SNAKE_CASE__			:      Any=0.0     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]=0.0     ,SCREAMING_SNAKE_CASE__			:      Dict=0.0     ,SCREAMING_SNAKE_CASE__			:      Tuple=0.02     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]=False     ,SCREAMING_SNAKE_CASE__			:      int=1_500     ,SCREAMING_SNAKE_CASE__			:      int=448     ,SCREAMING_SNAKE_CASE__			:      str=50_256     ,SCREAMING_SNAKE_CASE__			:      str=50_256     ,SCREAMING_SNAKE_CASE__			:      List[Any]=50_256     ,SCREAMING_SNAKE_CASE__			:      str=None     ,SCREAMING_SNAKE_CASE__			:      Optional[int]=[220, 50_256]     ,SCREAMING_SNAKE_CASE__			:      List[str]=False     ,SCREAMING_SNAKE_CASE__			:      Optional[int]=256     ,SCREAMING_SNAKE_CASE__			:      List[Any]=False     ,SCREAMING_SNAKE_CASE__			:      int=0.05     ,SCREAMING_SNAKE_CASE__			:      List[str]=10     ,SCREAMING_SNAKE_CASE__			:      List[Any]=2     ,SCREAMING_SNAKE_CASE__			:      str=0.0     ,SCREAMING_SNAKE_CASE__			:      Any=10     ,SCREAMING_SNAKE_CASE__			:      Any=0     ,SCREAMING_SNAKE_CASE__			:      str=7     ,**SCREAMING_SNAKE_CASE__			:      Optional[Any]     ,):
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					vocab_size
     SCREAMING_SNAKE_CASE:int						      =					num_mel_bins
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					d_model
     SCREAMING_SNAKE_CASE:Optional[int]						      =					encoder_layers
     SCREAMING_SNAKE_CASE:Tuple						      =					encoder_attention_heads
     SCREAMING_SNAKE_CASE:str						      =					decoder_layers
     SCREAMING_SNAKE_CASE:Dict						      =					decoder_attention_heads
     SCREAMING_SNAKE_CASE:List[Any]						      =					decoder_ffn_dim
     SCREAMING_SNAKE_CASE:Optional[int]						      =					encoder_ffn_dim
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					dropout
     SCREAMING_SNAKE_CASE:List[Any]						      =					attention_dropout
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					activation_dropout
     SCREAMING_SNAKE_CASE:Tuple						      =					activation_function
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					init_std
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					encoder_layerdrop
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					decoder_layerdrop
     SCREAMING_SNAKE_CASE:str						      =					use_cache
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					encoder_layers
     SCREAMING_SNAKE_CASE:Tuple						      =					scale_embedding  # scale factor will be sqrt(d_model) if True
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					max_source_positions
     SCREAMING_SNAKE_CASE:List[str]						      =					max_target_positions

     # Audio Classification-specific parameters. Feel free to ignore for other classes.
     SCREAMING_SNAKE_CASE:Tuple						      =					classifier_proj_size
     SCREAMING_SNAKE_CASE:List[str]						      =					use_weighted_layer_sum

     # fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
     SCREAMING_SNAKE_CASE:int						      =					apply_spec_augment
     SCREAMING_SNAKE_CASE:str						      =					mask_time_prob
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					mask_time_length
     SCREAMING_SNAKE_CASE:Any						      =					mask_time_min_masks
     SCREAMING_SNAKE_CASE:List[str]						      =					mask_feature_prob
     SCREAMING_SNAKE_CASE:Dict						      =					mask_feature_length
     SCREAMING_SNAKE_CASE:List[str]						      =					mask_feature_min_masks

     SCREAMING_SNAKE_CASE:Tuple						      =					median_filter_width

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





class 							_snake_case (       __a						):
   @property
   def     __UpperCamelCase						( self			:      int							):
     SCREAMING_SNAKE_CASE:Dict						      =					OrderedDict(
         [
             ("input_features", {0: "batch", 1: "feature_size", 2: "encoder_sequence"}),
         ]							)
     if self.use_past:
       SCREAMING_SNAKE_CASE:List[Any]						      =					{0: "batch"}
     else:
       SCREAMING_SNAKE_CASE:Any						      =					{0: "batch", 1: "decoder_sequence"}

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

     return common_inputs
   def     __UpperCamelCase						( self			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]     ,SCREAMING_SNAKE_CASE__			:      int = -1     ,SCREAMING_SNAKE_CASE__			:      int = -1     ,SCREAMING_SNAKE_CASE__			:      bool = False     ,SCREAMING_SNAKE_CASE__			:      Optional["TensorType"] = None     ,SCREAMING_SNAKE_CASE__			:      int = 22_050     ,SCREAMING_SNAKE_CASE__			:      float = 5.0     ,SCREAMING_SNAKE_CASE__			:      int = 220     ,):
     SCREAMING_SNAKE_CASE:Tuple						      =					OrderedDict()
     SCREAMING_SNAKE_CASE:str						      =					OnnxConfig.generate_dummy_inputs(
         self     ,preprocessor=preprocessor.feature_extractor     ,batch_size=snake_case__     ,framework=snake_case__     ,sampling_rate=snake_case__     ,time_duration=snake_case__     ,frequency=snake_case__     ,)
     SCREAMING_SNAKE_CASE:List[Any]						      =					encoder_inputs["input_features"].shape[2]
     SCREAMING_SNAKE_CASE:int						      =					encoder_sequence_length // 2 if self.use_past else seq_length

     SCREAMING_SNAKE_CASE:int						      =					super().generate_dummy_inputs(
         preprocessor.tokenizer     ,snake_case__     ,snake_case__     ,snake_case__     ,snake_case__							)

     SCREAMING_SNAKE_CASE:List[Any]						      =					encoder_inputs.pop("input_features"							)
     SCREAMING_SNAKE_CASE:Any						      =					decoder_inputs.pop("decoder_input_ids"							)

     if "past_key_values" in decoder_inputs:
       SCREAMING_SNAKE_CASE:str						      =					decoder_inputs.pop("past_key_values"							)

     return dummy_inputs







   @property
   def     __UpperCamelCase						( self			:      Tuple							):
     return 1e-3









'''simple docstring'''

from ....utils import logging


A_       						=							logging.get_logger(__name__)





class 							_snake_case (       _a						):
   def __init__( self			:      Optional[Any]     ,SCREAMING_SNAKE_CASE__			:      Optional[int]     ,SCREAMING_SNAKE_CASE__			:      Optional[Any]=None     ,SCREAMING_SNAKE_CASE__			:      Optional[int]=2_048							):
     SCREAMING_SNAKE_CASE:int						      =					config.__dict__
     SCREAMING_SNAKE_CASE:List[str]						      =					modal_hidden_size
     if num_labels:
       SCREAMING_SNAKE_CASE:str						      =					num_labels






