


from ...processing_utils import ProcessorMixin

class     snake_case      (							_UpperCamelCase						):
			'''simple docstring'''

			UpperCAmelCase							:							Dict							=			"""WhisperFeatureExtractor"""
			UpperCAmelCase							:							str							=			"""WhisperTokenizer"""

			def __init__(						self  :  Any				,				lowerCAmelCase_  :  Any				,				lowerCAmelCase_  :  int       )       ->       List[Any]:




								"""simple docstring"""






								super().__init__(UpperCamelCase__				,				UpperCamelCase__       )
								SCREAMING_SNAKE_CASE_						   =							self.feature_extractor
								SCREAMING_SNAKE_CASE_						   =							False

			def _lowercase			(						self  :  Tuple				,				lowerCAmelCase_  :  Optional[Any]=None				,				lowerCAmelCase_  :  int=None				,				lowerCAmelCase_  :  List[str]=True       )       ->       Any:




								"""simple docstring"""






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

			def __call__(						self  :  str				,				*lowerCAmelCase_  :  Any				,				**lowerCAmelCase_  :  Tuple       )       ->       Optional[Any]:




								"""simple docstring"""






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

								SCREAMING_SNAKE_CASE_						   =							kwargs.pop('''audio'''				,				UpperCamelCase__       )
								SCREAMING_SNAKE_CASE_						   =							kwargs.pop('''sampling_rate'''				,				UpperCamelCase__       )
								SCREAMING_SNAKE_CASE_						   =							kwargs.pop('''text'''				,				UpperCamelCase__       )
								if len(UpperCamelCase__       ) > 0:
													SCREAMING_SNAKE_CASE_						   =							args[0]
													SCREAMING_SNAKE_CASE_						   =							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:
													SCREAMING_SNAKE_CASE_						   =							self.feature_extractor(UpperCamelCase__				,				*UpperCamelCase__				,				sampling_rate=UpperCamelCase__				,				**UpperCamelCase__       )
								if text is not None:
													SCREAMING_SNAKE_CASE_						   =							self.tokenizer(UpperCamelCase__				,				**UpperCamelCase__       )

								if text is None:
													return inputs

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

			def _lowercase			(						self  :  List[Any]				,				*lowerCAmelCase_  :  Dict				,				**lowerCAmelCase_  :  Optional[Any]       )       ->       Optional[int]:




								"""simple docstring"""






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

			def _lowercase			(						self  :  List[str]				,				*lowerCAmelCase_  :  Tuple				,				**lowerCAmelCase_  :  Dict       )       ->       List[str]:




								"""simple docstring"""






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




			def _lowercase			(						self  :  List[str]				,				lowerCAmelCase_  :  str				,				lowerCAmelCase_  :  Optional[Any]="np"       )       ->       Dict:




								"""simple docstring"""






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



'''simple docstring'''






from __future__ import annotations

import unittest

from transformers import is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow


if is_tf_available():
   import numpy as np
   import tensorflow as tf

   from transformers import TFCamembertModel







@require_tf
@require_sentencepiece
@require_tokenizers
class lowercase_       (		unittest.TestCase			):







   """simple docstring"""

   @slow
   def 	__UpperCAmelCase   (      self      :			List[str]     )  ->			Any:
        _A    		=  TFCamembertModel.from_pretrained('jplu/tf-camembert-base'     )

        _A    		=  tf.convert_to_tensor(
            [[5, 1_21, 11, 6_60, 16, 7_30, 2_55_43, 1_10, 83, 6]], dtype=tf.intaa, )  # J'aime le camembert !"

        _A    		=  model(UpperCamelCase__     )['last_hidden_state']
        _A    		=  tf.TensorShape((1, 10, 7_68)     )
        self.assertEqual(output.shape, UpperCamelCase__     )
        # compare the actual values for a slice.
        _A    		=  tf.convert_to_tensor(
            [[[-0.0_254, 0.0_235, 0.1_027], [0.0_606, -0.1_811, -0.0_418], [-0.1_561, -0.1_127, 0.2_687]]], dtype=tf.floataa, )
        # camembert = torch.hub.load('pytorch/fairseq', 'camembert.v0')
        # camembert.eval()
        # expected_slice = roberta.model.forward(input_ids)[0][:, :3, :3].detach()

        self.assertTrue(np.allclose(output[:, :3, :3].numpy(), expected_slice.numpy(), atol=1e-4     )     )



