


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

_lowercase       :      List[Any]	=	logging.get_logger(__name__)

_lowercase       :      Union[str, Any]	=	{
    "openai/whisper-base": "https://huggingface.co/openai/whisper-base/resolve/main/config.json",
}

# fmt: off
_lowercase       :      Optional[Any]	=	[
    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
]
_lowercase       :      List[str]	=	[
    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       _UpperCamelCase    (					a__				):

				"""simple docstring"""







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

				def __init__(						self				,   a__=5_1865				,   a__=80				,   a__=6				,   a__=4				,   a__=6				,   a__=4				,   a__=1536				,   a__=1536				,   a__=0.0				,   a__=0.0				,   a__=5_0257				,   a__=True				,   a__=True				,   a__="gelu"				,   a__=256				,   a__=0.0				,   a__=0.0				,   a__=0.0				,   a__=0.02				,   a__=False				,   a__=1500				,   a__=448				,   a__=5_0256				,   a__=5_0256				,   a__=5_0256				,   a__=None				,   a__=[220, 5_0256]				,   a__=False				,   a__=256				,   a__=False				,   a__=0.05				,   a__=10				,   a__=2				,   a__=0.0				,   a__=10				,   a__=0				,   a__=7				,   **a__				,   )	->				Tuple:
					A								=				vocab_size
					A								=				num_mel_bins
					A								=				d_model
					A								=				encoder_layers
					A								=				encoder_attention_heads
					A								=				decoder_layers
					A								=				decoder_attention_heads
					A								=				decoder_ffn_dim
					A								=				encoder_ffn_dim
					A								=				dropout
					A								=				attention_dropout
					A								=				activation_dropout
					A								=				activation_function
					A								=				init_std
					A								=				encoder_layerdrop
					A								=				decoder_layerdrop
					A								=				use_cache
					A								=				encoder_layers
					A								=				scale_embedding  # scale factor will be sqrt(d_model) if True
					A								=				max_source_positions
					A								=				max_target_positions

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

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

					A								=				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    (					a__				):

				"""simple docstring"""







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

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

					return common_inputs

				def      _UpperCAmelCase					(						self				,   a__				,   a__ = -1				,   a__ = -1				,   a__ = False				,   a__ = None				,   a__ = 2_2050				,   a__ = 5.0				,   a__ = 220				,   )	->				Mapping[str, Any]:
					A								=				OrderedDict()
					A								=				OnnxConfig.generate_dummy_inputs(
					    self				,   preprocessor=preprocessor.feature_extractor				,   batch_size=lowerCamelCase_				,   framework=lowerCamelCase_				,   sampling_rate=lowerCamelCase_				,   time_duration=lowerCamelCase_				,   frequency=lowerCamelCase_				,   )
					A								=				encoder_inputs["""input_features"""].shape[2]
					A								=				encoder_sequence_length // 2 if self.use_past else seq_length

					A								=				super().generate_dummy_inputs(
					    preprocessor.tokenizer				,   lowerCamelCase_				,   lowerCamelCase_				,   lowerCamelCase_				,   lowerCamelCase_   )

					A								=				encoder_inputs.pop("""input_features"""   )
					A								=				decoder_inputs.pop("""decoder_input_ids"""   )

					if "past_key_values" in decoder_inputs:
						A								=				decoder_inputs.pop("""past_key_values"""   )

					return dummy_inputs

				@property
				def      _UpperCAmelCase					(						self   )	->				float:
					return 1e-3



import warnings
from typing import List, Optional, Union

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType






class       _UpperCamelCase    (					__snake_case				):

				"""simple docstring"""







				lowerCAmelCase 		= ['image_processor', 'tokenizer']
				lowerCAmelCase 		= 'ViltImageProcessor'
				lowerCAmelCase 		= ('BertTokenizer', 'BertTokenizerFast')

				def __init__(						self				,   a__=None				,   a__=None				,   **a__   )	->				Any:
					A								=				None
					if "feature_extractor" in kwargs:
						warnings.warn(
						    """The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"""
						    """ instead."""				,   a__				,   )
						A								=				kwargs.pop("""feature_extractor"""   )

					A								=				image_processor if image_processor is not None else feature_extractor
					if image_processor is None:
						raise ValueError("""You need to specify an `image_processor`."""   )
					if tokenizer is None:
						raise ValueError("""You need to specify a `tokenizer`."""   )

					super().__init__(a__				,   a__   )
					A								=				self.image_processor

				def __call__(						self				,   a__				,   a__ = None				,   a__ = True				,   a__ = False				,   a__ = None				,   a__ = None				,   a__ = 0				,   a__ = None				,   a__ = None				,   a__ = None				,   a__ = False				,   a__ = False				,   a__ = False				,   a__ = False				,   a__ = True				,   a__ = None				,   **a__				,   )	->				BatchEncoding:
					A								=				self.tokenizer(
					    text=a__				,   add_special_tokens=a__				,   padding=a__				,   truncation=a__				,   max_length=a__				,   stride=a__				,   pad_to_multiple_of=a__				,   return_token_type_ids=a__				,   return_attention_mask=a__				,   return_overflowing_tokens=a__				,   return_special_tokens_mask=a__				,   return_offsets_mapping=a__				,   return_length=a__				,   verbose=a__				,   return_tensors=a__				,   **a__				,   )
					# add pixel_values + pixel_mask
					A								=				self.image_processor(a__				,   return_tensors=a__   )
					encoding.update(a__   )

					return encoding

				def      _UpperCAmelCase					(						self				,   *a__				,   **a__   )	->				Union[str, Any]:
					return self.tokenizer.batch_decode(*a__				,   **a__   )

				def      _UpperCAmelCase					(						self				,   *a__				,   **a__   )	->				Any:
					return self.tokenizer.decode(*a__				,   **a__   )

				@property
				def      _UpperCAmelCase					(						self   )	->				int:
					A								=				self.tokenizer.model_input_names
					A								=				self.image_processor.model_input_names
					return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names   )   )

				@property
				def      _UpperCAmelCase					(						self   )	->				str:
					warnings.warn(
					    """`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."""				,   a__				,   )
					return self.image_processor_class

				@property
				def      _UpperCAmelCase					(						self   )	->				str:
					warnings.warn(
					    """`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."""				,   a__				,   )
					return self.image_processor



