






'''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

UpperCamelCase							=logging.get_logger(__name__)

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

# fmt: off
UpperCamelCase							=[
    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, 1_0563, 1_0786,
    1_1420, 1_1709, 1_1907, 1_3163, 1_3697, 1_3700, 1_4808, 1_5306, 1_6410, 1_6791,
    1_7992, 1_9203, 1_9510, 2_0724, 2_2305, 2_2935, 2_7007, 3_0109, 3_0420, 3_3409,
    3_4949, 4_0283, 4_0493, 4_0549, 4_7282, 4_9146, 5_0257, 5_0359, 5_0360, 5_0361
]
UpperCamelCase							=[
    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, 1_0428, 1_0929, 1_1938, 1_2033, 1_2331, 1_2562, 1_3793,
    1_4157, 1_4635, 1_5265, 1_5618, 1_6553, 1_6604, 1_8362, 1_8956, 2_0075, 2_1675,
    2_2520, 2_6130, 2_6161, 2_6435, 2_8279, 2_9464, 3_1650, 3_2302, 3_2470, 3_6865,
    4_2863, 4_7425, 4_9870, 5_0254, 5_0258, 5_0360, 5_0361, 5_0362
]




class     A    (      SCREAMING_SNAKE_CASE__						):






 """simple docstring"""





 __a			:						Optional[int]      =						'''whisper'''
 __a			:						List[Any]      =						['''past_key_values''']
 __a			:						Any      =						{'''num_attention_heads''': '''encoder_attention_heads''', '''hidden_size''': '''d_model'''}
 def __init__(							self			,     __lowerCAmelCase=5_18_65			,     __lowerCAmelCase=80			,     __lowerCAmelCase=6			,     __lowerCAmelCase=4			,     __lowerCAmelCase=6			,     __lowerCAmelCase=4			,     __lowerCAmelCase=15_36			,     __lowerCAmelCase=15_36			,     __lowerCAmelCase=0.0			,     __lowerCAmelCase=0.0			,     __lowerCAmelCase=5_02_57			,     __lowerCAmelCase=True			,     __lowerCAmelCase=True			,     __lowerCAmelCase="gelu"			,     __lowerCAmelCase=2_56			,     __lowerCAmelCase=0.0			,     __lowerCAmelCase=0.0			,     __lowerCAmelCase=0.0			,     __lowerCAmelCase=0.02			,     __lowerCAmelCase=False			,     __lowerCAmelCase=15_00			,     __lowerCAmelCase=4_48			,     __lowerCAmelCase=5_02_56			,     __lowerCAmelCase=5_02_56			,     __lowerCAmelCase=5_02_56			,     __lowerCAmelCase=None			,     __lowerCAmelCase=[2_20, 5_02_56]			,     __lowerCAmelCase=False			,     __lowerCAmelCase=2_56			,     __lowerCAmelCase=False			,     __lowerCAmelCase=0.05			,     __lowerCAmelCase=10			,     __lowerCAmelCase=2			,     __lowerCAmelCase=0.0			,     __lowerCAmelCase=10			,     __lowerCAmelCase=0			,     __lowerCAmelCase=7			,     **__lowerCAmelCase			,     ):
       UpperCamelCase_				:   Union[str, Any]					    =							vocab_size
       UpperCamelCase_				:   str					    =							num_mel_bins
       UpperCamelCase_				:   Optional[Any]					    =							d_model
       UpperCamelCase_				:   Optional[int]					    =							encoder_layers
       UpperCamelCase_				:   Optional[Any]					    =							encoder_attention_heads
       UpperCamelCase_				:   Any					    =							decoder_layers
       UpperCamelCase_				:   Dict					    =							decoder_attention_heads
       UpperCamelCase_				:   Optional[Any]					    =							decoder_ffn_dim
       UpperCamelCase_				:   Union[str, Any]					    =							encoder_ffn_dim
       UpperCamelCase_				:   Dict					    =							dropout
       UpperCamelCase_				:   str					    =							attention_dropout
       UpperCamelCase_				:   Optional[Any]					    =							activation_dropout
       UpperCamelCase_				:   Union[str, Any]					    =							activation_function
       UpperCamelCase_				:   str					    =							init_std
       UpperCamelCase_				:   Union[str, Any]					    =							encoder_layerdrop
       UpperCamelCase_				:   Tuple					    =							decoder_layerdrop
       UpperCamelCase_				:   Optional[int]					    =							use_cache
       UpperCamelCase_				:   str					    =							encoder_layers
       UpperCamelCase_				:   Tuple					    =							scale_embedding  # scale factor will be sqrt(d_model) if True
       UpperCamelCase_				:   List[str]					    =							max_source_positions
       UpperCamelCase_				:   Union[str, Any]					    =							max_target_positions

       # Audio Classification-specific parameters. Feel free to ignore for other classes.
       UpperCamelCase_				:   Tuple					    =							classifier_proj_size
       UpperCamelCase_				:   Optional[Any]					    =							use_weighted_layer_sum

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

       UpperCamelCase_				:   str					    =							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     A    (      SCREAMING_SNAKE_CASE__						):






 """simple docstring"""





 @property
 def   _UpperCAmelCase       (							self ):
       UpperCamelCase_				:   Optional[Any]					    =							OrderedDict(
           [
               ("""input_features""", {0: """batch""", 1: """feature_size""", 2: """encoder_sequence"""}),
           ] )
       if self.use_past:
             UpperCamelCase_				:   Any					    =							{0: """batch"""}
       else:
             UpperCamelCase_				:   List[str]					    =							{0: """batch""", 1: """decoder_sequence"""}

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

       return common_inputs
 def   _UpperCAmelCase       (							self			,     __lowerCAmelCase			,     __lowerCAmelCase = -1			,     __lowerCAmelCase = -1			,     __lowerCAmelCase = False			,     __lowerCAmelCase = None			,     __lowerCAmelCase = 2_20_50			,     __lowerCAmelCase = 5.0			,     __lowerCAmelCase = 2_20			,     ):
       UpperCamelCase_				:   Any					    =							OrderedDict()
       UpperCamelCase_				:   List[Any]					    =							OnnxConfig.generate_dummy_inputs(
           self			,     preprocessor=preprocessor.feature_extractor			,     batch_size=__lowerCAmelCase			,     framework=__lowerCAmelCase			,     sampling_rate=__lowerCAmelCase			,     time_duration=__lowerCAmelCase			,     frequency=__lowerCAmelCase			,     )
       UpperCamelCase_				:   int					    =							encoder_inputs["""input_features"""].shape[2]
       UpperCamelCase_				:   Tuple					    =							encoder_sequence_length // 2 if self.use_past else seq_length

       UpperCamelCase_				:   List[Any]					    =							super().generate_dummy_inputs(
           preprocessor.tokenizer			,     __lowerCAmelCase			,     __lowerCAmelCase			,     __lowerCAmelCase			,     __lowerCAmelCase )

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

       if "past_key_values" in decoder_inputs:
             UpperCamelCase_				:   int					    =							decoder_inputs.pop("""past_key_values""" )

       return dummy_inputs





 @property
 def   _UpperCAmelCase       (							self ):
       return 1E-3














'''simple docstring'''

import pytest

import datasets


# Import fixture modules as plugins
UpperCamelCase							=["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"]



def 							snake_case					(     a_							: List[str]    ,   a_							: Optional[Any]	)       ->				Union[str, Any]:





      """simple docstring"""

      for item in items:
            if any(marker in item.keywords for marker in ["""integration""", """unit"""]	):
                  continue
            item.add_marker(pytest.mark.unit	)



def 							snake_case					(     a_							: Optional[int]	)       ->				Optional[Any]:





      """simple docstring"""

      config.addinivalue_line("""markers"""    ,   """torchaudio_latest: mark test to run with torchaudio>=0.12"""	)



@pytest.fixture(autouse=a_	)
def 							snake_case					(     a_							: Any    ,   a_							: Optional[int]	)       ->				Tuple:





      """simple docstring"""

      UpperCamelCase_				:   Optional[Any]					    =							tmp_path_factory.getbasetemp() / """cache"""
      UpperCamelCase_				:   str					    =							test_hf_cache_home / """datasets"""
      UpperCamelCase_				:   Any					    =							test_hf_cache_home / """metrics"""
      UpperCamelCase_				:   List[Any]					    =							test_hf_cache_home / """modules"""
      monkeypatch.setattr("""datasets.config.HF_DATASETS_CACHE"""    ,   str(a_	)	)
      monkeypatch.setattr("""datasets.config.HF_METRICS_CACHE"""    ,   str(a_	)	)
      monkeypatch.setattr("""datasets.config.HF_MODULES_CACHE"""    ,   str(a_	)	)
      UpperCamelCase_				:   List[Any]					    =							test_hf_datasets_cache / """downloads"""
      monkeypatch.setattr("""datasets.config.DOWNLOADED_DATASETS_PATH"""    ,   str(a_	)	)
      UpperCamelCase_				:   Any					    =							test_hf_datasets_cache / """downloads""" / """extracted"""
      monkeypatch.setattr("""datasets.config.EXTRACTED_DATASETS_PATH"""    ,   str(a_	)	)



@pytest.fixture(autouse=a_    ,   scope="""session"""	)
def 							snake_case					(     )       ->				Any:





      """simple docstring"""

      datasets.disable_progress_bar()



@pytest.fixture(autouse=a_	)
def 							snake_case					(     a_							: Optional[int]	)       ->				Union[str, Any]:





      """simple docstring"""

      monkeypatch.setattr("""datasets.config.HF_UPDATE_DOWNLOAD_COUNTS"""    ,   a_	)



@pytest.fixture
def 							snake_case					(     a_							: int	)       ->				Union[str, Any]:





      """simple docstring"""

      monkeypatch.setattr("""sqlalchemy.util.deprecations.SILENCE_UBER_WARNING"""    ,   a_	)






