


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

lowerCamelCase__    	=     logging.get_logger(__name__)

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

# fmt: off
lowerCamelCase__    	=     [
    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, 1_058, 1_220, 1_267, 1_279, 1_303, 1_343, 1_377,
    1_391, 1_635, 1_782, 1_875, 2_162, 2_361, 2_488, 3_467, 4_008, 4_211,
    4_600, 4_808, 5_299, 5_855, 6_329, 7_203, 9_609, 9_959, 10_563, 10_786,
    11_420, 11_709, 11_907, 13_163, 13_697, 13_700, 14_808, 15_306, 16_410, 16_791,
    17_992, 19_203, 19_510, 20_724, 22_305, 22_935, 27_007, 30_109, 30_420, 33_409,
    34_949, 40_283, 40_493, 40_549, 47_282, 49_146, 50_257, 50_359, 50_360, 50_361
]
lowerCamelCase__    	=     [
    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, 1_350, 1_853, 1_982, 2_460, 2_627,
    3_246, 3_253, 3_268, 3_536, 3_846, 3_961, 4_183, 4_667, 6_585, 6_647,
    7_273, 9_061, 9_383, 10_428, 10_929, 11_938, 12_033, 12_331, 12_562, 13_793,
    14_157, 14_635, 15_265, 15_618, 16_553, 16_604, 18_362, 18_956, 20_075, 21_675,
    22_520, 26_130, 26_161, 26_435, 28_279, 29_464, 31_650, 32_302, 32_470, 36_865,
    42_863, 47_425, 49_870, 50_254, 50_258, 50_360, 50_361, 50_362
]






class 	lowerCAmelCase__			(			UpperCAmelCase__	):
			lowerCAmelCase :	List[str]          =     "whisper"
			lowerCAmelCase :	List[str]          =     ["past_key_values"]
			lowerCAmelCase :	List[str]          =     {"num_attention_heads": "encoder_attention_heads", "hidden_size": "d_model"}




			def __init__(		self  :     List[str]	,  lowerCamelCase__  :     str=5_18_65	,  lowerCamelCase__  :     str=80	,  lowerCamelCase__  :     Dict=6	,  lowerCamelCase__  :     Tuple=4	,  lowerCamelCase__  :     Tuple=6	,  lowerCamelCase__  :     int=4	,  lowerCamelCase__  :     Tuple=15_36	,  lowerCamelCase__  :     Tuple=15_36	,  lowerCamelCase__  :     Union[str, Any]=0.0	,  lowerCamelCase__  :     Optional[int]=0.0	,  lowerCamelCase__  :     List[Any]=5_02_57	,  lowerCamelCase__  :     List[Any]=True	,  lowerCamelCase__  :     Union[str, Any]=True	,  lowerCamelCase__  :     Union[str, Any]="gelu"	,  lowerCamelCase__  :     Optional[int]=2_56	,  lowerCamelCase__  :     Any=0.0	,  lowerCamelCase__  :     Any=0.0	,  lowerCamelCase__  :     Dict=0.0	,  lowerCamelCase__  :     int=0.0_2	,  lowerCamelCase__  :     Tuple=False	,  lowerCamelCase__  :     List[str]=15_00	,  lowerCamelCase__  :     List[Any]=4_48	,  lowerCamelCase__  :     Optional[int]=5_02_56	,  lowerCamelCase__  :     Any=5_02_56	,  lowerCamelCase__  :     Optional[int]=5_02_56	,  lowerCamelCase__  :     Any=None	,  lowerCamelCase__  :     Optional[int]=[2_20, 5_02_56]	,  lowerCamelCase__  :     List[str]=False	,  lowerCamelCase__  :     Optional[Any]=2_56	,  lowerCamelCase__  :     str=False	,  lowerCamelCase__  :     Optional[int]=0.0_5	,  lowerCamelCase__  :     Any=10	,  lowerCamelCase__  :     Union[str, Any]=2	,  lowerCamelCase__  :     int=0.0	,  lowerCamelCase__  :     Optional[int]=10	,  lowerCamelCase__  :     Dict=0	,  lowerCamelCase__  :     Union[str, Any]=7	,  **lowerCamelCase__  :     Any	,  )   ->int:



					'''simple docstring'''







					_UpperCAmelCase		:       Any								=      vocab_size
					_UpperCAmelCase		:       Optional[Any]								=      num_mel_bins
					_UpperCAmelCase		:       List[str]								=      d_model
					_UpperCAmelCase		:       Union[str, Any]								=      encoder_layers
					_UpperCAmelCase		:       Union[str, Any]								=      encoder_attention_heads
					_UpperCAmelCase		:       str								=      decoder_layers
					_UpperCAmelCase		:       Any								=      decoder_attention_heads
					_UpperCAmelCase		:       str								=      decoder_ffn_dim
					_UpperCAmelCase		:       Tuple								=      encoder_ffn_dim
					_UpperCAmelCase		:       List[str]								=      dropout
					_UpperCAmelCase		:       str								=      attention_dropout
					_UpperCAmelCase		:       Union[str, Any]								=      activation_dropout
					_UpperCAmelCase		:       Union[str, Any]								=      activation_function
					_UpperCAmelCase		:       Dict								=      init_std
					_UpperCAmelCase		:       List[str]								=      encoder_layerdrop
					_UpperCAmelCase		:       Union[str, Any]								=      decoder_layerdrop
					_UpperCAmelCase		:       Any								=      use_cache
					_UpperCAmelCase		:       Optional[int]								=      encoder_layers
					_UpperCAmelCase		:       Optional[Any]								=      scale_embedding  # scale factor will be sqrt(d_model) if True
					_UpperCAmelCase		:       Union[str, Any]								=      max_source_positions
					_UpperCAmelCase		:       Any								=      max_target_positions

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

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

					_UpperCAmelCase		:       Tuple								=      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 	lowerCAmelCase__			(			UpperCAmelCase__	):




			@property
			def 							lowerCAmelCase__    (		self  :     List[Any] )   ->Mapping[str, Mapping[int, str]]:



					'''simple docstring'''







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

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

					return common_inputs




			def 							lowerCAmelCase__    (		self  :     Any	,  lowerCamelCase__  :     Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]	,  lowerCamelCase__  :     int = -1	,  lowerCamelCase__  :     int = -1	,  lowerCamelCase__  :     bool = False	,  lowerCamelCase__  :     Optional["TensorType"] = None	,  lowerCamelCase__  :     int = 2_20_50	,  lowerCamelCase__  :     float = 5.0	,  lowerCamelCase__  :     int = 2_20	,  )   ->Mapping[str, Any]:



					'''simple docstring'''







					_UpperCAmelCase		:       Dict								=      OrderedDict()
					_UpperCAmelCase		:       Optional[int]								=      OnnxConfig.generate_dummy_inputs(
					    self	,  preprocessor=preprocessor.feature_extractor	,  batch_size=lowerCamelCase__	,  framework=lowerCamelCase__	,  sampling_rate=lowerCamelCase__	,  time_duration=lowerCamelCase__	,  frequency=lowerCamelCase__	,  )
					_UpperCAmelCase		:       List[Any]								=      encoder_inputs["input_features"].shape[2]
					_UpperCAmelCase		:       int								=      encoder_sequence_length // 2 if self.use_past else seq_length

					_UpperCAmelCase		:       str								=      super().generate_dummy_inputs(
					    preprocessor.tokenizer	,  lowerCamelCase__	,  lowerCamelCase__	,  lowerCamelCase__	,  lowerCamelCase__ )

					_UpperCAmelCase		:       Optional[int]								=      encoder_inputs.pop("input_features" )
					_UpperCAmelCase		:       int								=      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 							lowerCAmelCase__    (		self  :     int )   ->float:



					'''simple docstring'''







					return 1E-3







'''simple docstring'''


from math import factorial






class 	lowerCAmelCase__			:




			def __init__(		self  :     int	,  lowerCamelCase__  :     Union[str, Any]	,  lowerCamelCase__  :     str )   ->Dict:



					'''simple docstring'''







					_UpperCAmelCase		:       Optional[Any]								=      real
					if isinstance(lowerCamelCase__	,  lowerCamelCase__ ):
							_UpperCAmelCase		:       Any								=      [1] * rank
					else:
							_UpperCAmelCase		:       Dict								=      rank




			def __repr__(		self  :     str )   ->List[str]:



					'''simple docstring'''







					return (
					    F"""{self.real}+"""
					    F"""{'+'.join(str(lowerCamelCase__ )+'E'+str(n+1 )for n,dual in enumerate(self.duals ) )}"""
					)




			def 							lowerCAmelCase__    (		self  :     Dict )   ->Tuple:



					'''simple docstring'''







					_UpperCAmelCase		:       Union[str, Any]								=      self.duals.copy()
					while cur[-1] == 0:
							cur.pop(-1 )
					return Dual(self.real	,  lowerCamelCase__ )




			def __add__(		self  :     Dict	,  lowerCamelCase__  :     List[Any] )   ->Any:



					'''simple docstring'''







					if not isinstance(lowerCamelCase__	,  lowerCamelCase__ ):
							return Dual(self.real + other	,  self.duals )
					_UpperCAmelCase		:       Optional[int]								=      self.duals.copy()
					_UpperCAmelCase		:       Optional[int]								=      other.duals.copy()
					if len(lowerCamelCase__ ) > len(lowerCamelCase__ ):
							o_dual.extend([1] * (len(lowerCamelCase__ ) - len(lowerCamelCase__ )) )
					elif len(lowerCamelCase__ ) < len(lowerCamelCase__ ):
							s_dual.extend([1] * (len(lowerCamelCase__ ) - len(lowerCamelCase__ )) )
					_UpperCAmelCase		:       Union[str, Any]								=      []
					for i in range(len(lowerCamelCase__ ) ):
							new_duals.append(s_dual[i] + o_dual[i] )
					return Dual(self.real + other.real	,  lowerCamelCase__ )

			lowerCAmelCase :	Tuple          =     __add__




			def __sub__(		self  :     List[Any]	,  lowerCamelCase__  :     Union[str, Any] )   ->Dict:



					'''simple docstring'''







					return self + other * -1




			def __mul__(		self  :     List[str]	,  lowerCamelCase__  :     Optional[Any] )   ->Union[str, Any]:



					'''simple docstring'''







					if not isinstance(lowerCamelCase__	,  lowerCamelCase__ ):
							_UpperCAmelCase		:       Optional[int]								=      []
							for i in self.duals:
									new_duals.append(i * other )
							return Dual(self.real * other	,  lowerCamelCase__ )
					_UpperCAmelCase		:       Union[str, Any]								=      [0] * (len(self.duals ) + len(other.duals ) + 1)
					for i, item in enumerate(self.duals ):
							for j, jtem in enumerate(other.duals ):
									new_duals[i + j + 1] += item * jtem
					for k in range(len(self.duals ) ):
							new_duals[k] += self.duals[k] * other.real
					for index in range(len(other.duals ) ):
							new_duals[index] += other.duals[index] * self.real
					return Dual(self.real * other.real	,  lowerCamelCase__ )

			lowerCAmelCase :	Union[str, Any]          =     __mul__




			def __truediv__(		self  :     Optional[Any]	,  lowerCamelCase__  :     List[Any] )   ->Union[str, Any]:



					'''simple docstring'''







					if not isinstance(lowerCamelCase__	,  lowerCamelCase__ ):
							_UpperCAmelCase		:       Union[str, Any]								=      []
							for i in self.duals:
									new_duals.append(i / other )
							return Dual(self.real / other	,  lowerCamelCase__ )
					raise ValueError




			def __floordiv__(		self  :     str	,  lowerCamelCase__  :     str )   ->List[str]:



					'''simple docstring'''







					if not isinstance(lowerCamelCase__	,  lowerCamelCase__ ):
							_UpperCAmelCase		:       Tuple								=      []
							for i in self.duals:
									new_duals.append(i // other )
							return Dual(self.real // other	,  lowerCamelCase__ )
					raise ValueError






			def __pow__(		self  :     Tuple	,  lowerCamelCase__  :     Optional[Any] )   ->Optional[int]:



					'''simple docstring'''







					if n < 0 or isinstance(lowerCamelCase__	,  lowerCamelCase__ ):
							raise ValueError("power must be a positive integer" )
					if n == 0:
							return 1
					if n == 1:
							return self
					_UpperCAmelCase		:       str								=      self
					for _ in range(n - 1 ):
							x *= self
					return x






def  __lowerCAmelCase (__lowerCAmelCase      , __lowerCAmelCase      , __lowerCAmelCase   ):
		if not callable(__lowerCAmelCase   ):
				raise ValueError("differentiate() requires a function as input for func"   )
		if not isinstance(__lowerCAmelCase      , (float, int)   ):
				raise ValueError("differentiate() requires a float as input for position"   )
		if not isinstance(__lowerCAmelCase      , __lowerCAmelCase   ):
				raise ValueError("differentiate() requires an int as input for order"   )
		_UpperCAmelCase		:       int								=      Dual(__lowerCAmelCase      , 1   )
		_UpperCAmelCase		:       Optional[int]								=      func(__lowerCAmelCase   )
		if order == 0:
				return result.real
		return result.duals[order - 1] * factorial(__lowerCAmelCase   )


if __name__ == "__main__":
						import doctest

						doctest.testmod()






						def  __lowerCAmelCase (__lowerCAmelCase   ):
								return y**2 * y**4





						print(differentiate(f, 9, 2))



