

from ...processing_utils import ProcessorMixin



class    _a						(__magic_name__    ):


					'''simple docstring'''






					UpperCAmelCase__:       Union[str, Any]  							=	'''WhisperFeatureExtractor'''
					UpperCAmelCase__:       Any  							=	'''WhisperTokenizer'''






					def __init__(			self   ,	A__   ,	A__      ):
						super().__init__(A__   ,	A__      )
						A__							:   Optional[Any]					       =		self.feature_extractor
						A__							:   Tuple					       =		False






					def   __A      (			self   ,	A__=None   ,	A__=None   ,	A__=True      ):
						return self.tokenizer.get_decoder_prompt_ids(task=A__   ,	language=A__   ,	no_timestamps=A__      )






					def __call__(			self   ,	*A__   ,	**A__      ):
						# For backward compatibility
						if self._in_target_context_manager:
							return self.current_processor(*A__   ,	**A__      )

						A__							:   Optional[Any]					       =		kwargs.pop("""audio"""   ,	A__      )
						A__							:   Optional[int]					       =		kwargs.pop("""sampling_rate"""   ,	A__      )
						A__							:   Union[str, Any]					       =		kwargs.pop("""text"""   ,	A__      )
						if len(A__      ) > 0:
							A__							:   int					       =		args[0]
							A__							:   List[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:
							A__							:   Tuple					       =		self.feature_extractor(A__   ,	*A__   ,	sampling_rate=A__   ,	**A__      )
						if text is not None:
							A__							:   Tuple					       =		self.tokenizer(A__   ,	**A__      )

						if text is None:
							return inputs

						elif audio is None:
							return encodings
						else:
							A__							:   int					       =		encodings["""input_ids"""]
							return inputs






					def   __A      (			self   ,	*A__   ,	**A__      ):
						return self.tokenizer.batch_decode(*A__   ,	**A__      )






					def   __A      (			self   ,	*A__   ,	**A__      ):
						return self.tokenizer.decode(*A__   ,	**A__      )






					def   __A      (			self   ,	A__   ,	A__="np"      ):
						return self.tokenizer.get_prompt_ids(A__   ,	return_tensors=A__      )






import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device


if is_torch_available():
	from transformers import AutoModelForSeqaSeqLM, AutoTokenizer



@require_torch
@require_sentencepiece
@require_tokenizers
class    _a						(unittest.TestCase    ):


					'''simple docstring'''






					@slow
					def   __A      (			self      ):
						A__							:   Optional[Any]					       =		AutoModelForSeqaSeqLM.from_pretrained("""google/mt5-small"""   ,	return_dict=A__      ).to(A__      )
						A__							:   str					       =		AutoTokenizer.from_pretrained("""google/mt5-small"""      )

						A__							:   int					       =		tokenizer("""Hello there"""   ,	return_tensors="""pt"""      ).input_ids
						A__							:   List[Any]					       =		tokenizer("""Hi I am"""   ,	return_tensors="""pt"""      ).input_ids

						A__							:   Union[str, Any]					       =		model(input_ids.to(A__      )   ,	labels=labels.to(A__      )      ).loss
						A__							:   Union[str, Any]					       =		-(labels.shape[-1] * loss.item())

						A__							:   Any					       =		-8_4.9_1_2_7
						self.assertTrue(abs(mtf_score - EXPECTED_SCORE      ) < 1e-4      )



