

'''simple docstring'''
from ...processing_utils import ProcessorMixin


class    a__  (							__lowerCamelCase  ):
   _SCREAMING_SNAKE_CASE    :     int	       =							"""WhisperFeatureExtractor"""
   _SCREAMING_SNAKE_CASE    :     Optional[int]	       =							"""WhisperTokenizer"""


   def __init__( self			,				_UpperCamelCase			,				_UpperCamelCase  ):





      """simple docstring"""





      super().__init__(__lowercase			,				__lowercase  )
      _lowercase			:      List[str]			     =   self.feature_extractor
      _lowercase			:      Optional[Any]			     =   False


   def 						_lowerCamelCase   ( self			,				_UpperCamelCase=None			,				_UpperCamelCase=None			,				_UpperCamelCase=True  ):





      """simple docstring"""





      return self.tokenizer.get_decoder_prompt_ids(task=__lowercase			,				language=__lowercase			,				no_timestamps=__lowercase  )


   def __call__( self			,				*_UpperCamelCase			,				**_UpperCamelCase  ):





      """simple docstring"""





      if self._in_target_context_manager:
         return self.current_processor(*__lowercase			,				**__lowercase  )

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

      if text is None:
         return inputs

      elif audio is None:
         return encodings
      else:
         _lowercase			:      Optional[Any]			     =   encodings['''input_ids''']
         return inputs


   def 						_lowerCamelCase   ( self			,				*_UpperCamelCase			,				**_UpperCamelCase  ):





      """simple docstring"""





      return self.tokenizer.batch_decode(*__lowercase			,				**__lowercase  )


   def 						_lowerCamelCase   ( self			,				*_UpperCamelCase			,				**_UpperCamelCase  ):





      """simple docstring"""





      return self.tokenizer.decode(*__lowercase			,				**__lowercase  )






   def 						_lowerCamelCase   ( self			,				_UpperCamelCase			,				_UpperCamelCase="np"  ):





      """simple docstring"""





      return self.tokenizer.get_prompt_ids(__lowercase			,				return_tensors=__lowercase  )











import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
				import torch

				from transformers.activations import gelu_new, gelu_python, get_activation


@require_torch
class       a							(			unittest.TestCase				):



		def 	__lowerCamelCase			(     self     :Union[str, Any]  ):
						snake_case__	:      Union[str, Any]     		=	torch.tensor([-1_0_0, -1, -0.1, 0, 0.1, 1.0, 1_0_0]  )
						snake_case__	:      int     		=	get_activation('''gelu'''  )
						self.assertTrue(torch.allclose(gelu_python(__lowercase  )   ,torch_builtin(__lowercase  )  )  )
						self.assertFalse(torch.allclose(gelu_python(__lowercase  )   ,gelu_new(__lowercase  )  )  )



		def 	__lowerCamelCase			(     self     :Union[str, Any]  ):
						snake_case__	:      List[Any]     		=	torch.tensor([-1_0_0, -1, -0.1, 0, 0.1, 1.0, 1_0_0]  )
						snake_case__	:      Union[str, Any]     		=	get_activation('''gelu'''  )
						snake_case__	:      int     		=	get_activation('''gelu_10'''  )

						snake_case__	:      Optional[int]     		=	torch_builtin(__lowercase  )
						snake_case__	:      str     		=	geluaa(__lowercase  )

						snake_case__	:      Tuple     		=	torch.where(y_gelu_aa < 10.0   ,1   ,0  )

						self.assertTrue(torch.max(__lowercase  ).item() == 10.0  )
						self.assertTrue(torch.allclose(y_gelu * clipped_mask   ,y_gelu_aa * clipped_mask  )  )



		def 	__lowerCamelCase			(     self     :Any  ):
						get_activation('''gelu'''  )
						get_activation('''gelu_10'''  )
						get_activation('''gelu_fast'''  )
						get_activation('''gelu_new'''  )
						get_activation('''gelu_python'''  )
						get_activation('''gelu_pytorch_tanh'''  )
						get_activation('''linear'''  )
						get_activation('''mish'''  )
						get_activation('''quick_gelu'''  )
						get_activation('''relu'''  )
						get_activation('''sigmoid'''  )
						get_activation('''silu'''  )
						get_activation('''swish'''  )
						get_activation('''tanh'''  )
						with self.assertRaises(__lowercase  ):
										get_activation('''bogus'''  )
						with self.assertRaises(__lowercase  ):
										get_activation(__lowercase  )






		def 	__lowerCamelCase			(     self     :Optional[int]  ):
						snake_case__	:      str     		=	get_activation('''gelu'''  )
						snake_case__	:      List[Any]     		=	1
						snake_case__	:      Optional[Any]     		=	get_activation('''gelu'''  )
						self.assertEqual(acta.a   ,1  )
						with self.assertRaises(__lowercase  ):
										snake_case__	:      str     		=	acta.a

