
"""simple docstring"""

from ...processing_utils import ProcessorMixin






class 	_lowercase       (    __UpperCAmelCase		):
	lowercase_				=     'WhisperFeatureExtractor'
	lowercase_				=     'WhisperTokenizer'




	def __init__(			self		,			UpperCAmelCase_		,			UpperCAmelCase_ )		->							List[Any]:
			super().__init__(UpperCAmelCase_		,			UpperCAmelCase_ )
			lowerCamelCase					:      Any          =   self.feature_extractor
			lowerCamelCase					:      Optional[int]          =   False




	def       _UpperCamelCase   (			self		,			UpperCAmelCase_=None		,			UpperCAmelCase_=None		,			UpperCAmelCase_=True )		->							Optional[Any]:
			return self.tokenizer.get_decoder_prompt_ids(task=UpperCAmelCase_		,			language=UpperCAmelCase_		,			no_timestamps=UpperCAmelCase_ )




	def __call__(			self		,			*UpperCAmelCase_		,			**UpperCAmelCase_ )		->							int:
			# For backward compatibility
			if self._in_target_context_manager:
					return self.current_processor(*UpperCAmelCase_		,			**UpperCAmelCase_ )

			lowerCamelCase					:      int          =   kwargs.pop('audio'		,			UpperCAmelCase_ )
			lowerCamelCase					:      Optional[int]          =   kwargs.pop('sampling_rate'		,			UpperCAmelCase_ )
			lowerCamelCase					:      Tuple          =   kwargs.pop('text'		,			UpperCAmelCase_ )
			if len(UpperCAmelCase_ ) > 0:
					lowerCamelCase					:      Union[str, Any]          =   args[0]
					lowerCamelCase					:      Optional[Any]          =   args[1:]

			if audio is None and text is None:
					raise ValueError('You need to specify either an `audio` or `text` input to process.' )

			if audio is not None:
					lowerCamelCase					:      List[str]          =   self.feature_extractor(UpperCAmelCase_		,			*UpperCAmelCase_		,			sampling_rate=UpperCAmelCase_		,			**UpperCAmelCase_ )
			if text is not None:
					lowerCamelCase					:      Optional[Any]          =   self.tokenizer(UpperCAmelCase_		,			**UpperCAmelCase_ )

			if text is None:
					return inputs

			elif audio is None:
					return encodings
			else:
					lowerCamelCase					:      int          =   encodings['input_ids']
					return inputs




	def       _UpperCamelCase   (			self		,			*UpperCAmelCase_		,			**UpperCAmelCase_ )		->							int:
			return self.tokenizer.batch_decode(*UpperCAmelCase_		,			**UpperCAmelCase_ )




	def       _UpperCamelCase   (			self		,			*UpperCAmelCase_		,			**UpperCAmelCase_ )		->							Tuple:
			return self.tokenizer.decode(*UpperCAmelCase_		,			**UpperCAmelCase_ )




	def       _UpperCamelCase   (			self		,			UpperCAmelCase_		,			UpperCAmelCase_="np" )		->							List[Any]:
			return self.tokenizer.get_prompt_ids(UpperCAmelCase_		,			return_tensors=UpperCAmelCase_ )








"""simple docstring"""

import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


_A						=			logging.get_logger(__name__)






class 	_lowercase       (    __UpperCAmelCase		):
	lowercase_				=     'encoder-decoder'
	lowercase_				=     True




	def __init__(			self		,			**UpperCAmelCase_ )		->							str:
			super().__init__(**UpperCAmelCase_ )
			assert (
			    "encoder" in kwargs and "decoder" in kwargs
			), "Config has to be initialized with encoder and decoder config"
			lowerCamelCase					:      List[Any]          =   kwargs.pop('encoder' )
			lowerCamelCase					:      Optional[int]          =   encoder_config.pop('model_type' )
			lowerCamelCase					:      str          =   kwargs.pop('decoder' )
			lowerCamelCase					:      Dict          =   decoder_config.pop('model_type' )

			from ..auto.configuration_auto import AutoConfig

			lowerCamelCase					:      int          =   AutoConfig.for_model(UpperCAmelCase_		,			**UpperCAmelCase_ )
			lowerCamelCase					:      List[str]          =   AutoConfig.for_model(UpperCAmelCase_		,			**UpperCAmelCase_ )
			lowerCamelCase					:      List[str]          =   True




	@classmethod
	def       _UpperCamelCase   (			cls		,			UpperCAmelCase_		,			UpperCAmelCase_		,			**UpperCAmelCase_ )		->							PretrainedConfig:
			logger.info('Set `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config' )
			lowerCamelCase					:      str          =   True
			lowerCamelCase					:      Optional[Any]          =   True

			return cls(encoder=encoder_config.to_dict()		,			decoder=decoder_config.to_dict()		,			**UpperCAmelCase_ )




	def       _UpperCamelCase   (			self )		->							Union[str, Any]:
			lowerCamelCase					:      Union[str, Any]          =   copy.deepcopy(self.__dict__ )
			lowerCamelCase					:      Union[str, Any]          =   self.encoder.to_dict()
			lowerCamelCase					:      List[Any]          =   self.decoder.to_dict()
			lowerCamelCase					:      Tuple          =   self.__class__.model_type
			return output






