




import inspect

from diffusers.utils import is_flax_available
from diffusers.utils.testing_utils import require_flax


if is_flax_available():
   import jax

@require_flax
class      UpperCAmelCase						:






   def  _a						(	self   :       Optional[Any]     )->			List[Any]:
     _lowercase     ,					_lowercase: Union[str, Any]						     =    self.prepare_init_args_and_inputs_for_common()

     _lowercase: Optional[Any]						     =    self.model_class(**UpperCamelCase_     )
     _lowercase: Tuple						     =    model.init(inputs_dict['prng_key']						,					inputs_dict['sample']     )
     jax.lax.stop_gradient(UpperCamelCase_     )

     _lowercase: Tuple						     =    model.apply(UpperCamelCase_						,					inputs_dict['sample']     )

     if isinstance(UpperCamelCase_						,					UpperCamelCase_     ):
       _lowercase: Optional[int]						     =    output.sample

     self.assertIsNotNone(UpperCamelCase_     )
     _lowercase: List[Any]						     =    inputs_dict['sample'].shape
     self.assertEqual(output.shape						,					UpperCamelCase_						,					'Input and output shapes do not match'     )






   def  _a						(	self   :       Union[str, Any]     )->			Tuple:
     _lowercase     ,					_lowercase: Tuple						     =    self.prepare_init_args_and_inputs_for_common()

     _lowercase: List[str]						     =    16
     _lowercase: List[Any]						     =    (16, 32)

     _lowercase: Any						     =    self.model_class(**UpperCamelCase_     )
     _lowercase: int						     =    model.init(inputs_dict['prng_key']						,					inputs_dict['sample']     )
     jax.lax.stop_gradient(UpperCamelCase_     )

     _lowercase: str						     =    model.apply(UpperCamelCase_						,					inputs_dict['sample']     )

     if isinstance(UpperCamelCase_						,					UpperCamelCase_     ):
       _lowercase: int						     =    output.sample

     self.assertIsNotNone(UpperCamelCase_     )
     _lowercase: Any						     =    inputs_dict['sample'].shape
     self.assertEqual(output.shape						,					UpperCamelCase_						,					'Input and output shapes do not match'     )






   def  _a						(	self   :       Dict     )->			Optional[int]:
     _lowercase: str						     =    'kwargs' in inspect.signature(self.model_class.__init__     ).parameters
     _lowercase: int						     =    len(self.model_class._deprecated_kwargs     ) > 0

     if has_kwarg_in_model_class and not has_deprecated_kwarg:
       raise ValueError(
           f'{self.model_class} has `**kwargs` in its __init__ method but has not defined any deprecated kwargs'
           ' under the `_deprecated_kwargs` class attribute. Make sure to either remove `**kwargs` if there are'
           ' no deprecated arguments or add the deprecated argument with `_deprecated_kwargs ='
           ' [<deprecated_argument>]`'     )

     if not has_kwarg_in_model_class and has_deprecated_kwarg:
       raise ValueError(
           f'{self.model_class} doesn\'t have `**kwargs` in its __init__ method but has defined deprecated kwargs'
           ' under the `_deprecated_kwargs` class attribute. Make sure to either add the `**kwargs` argument to'
           f' {self.model_class}.__init__ if there are deprecated arguments or remove the deprecated argument'
           ' from `_deprecated_kwargs = [<deprecated_argument>]`'     )






import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin

class      UpperCAmelCase						(			A   ):
   __SCREAMING_SNAKE_CASE		:							Optional[Any]							=					"AutoFeatureExtractor"
   __SCREAMING_SNAKE_CASE		:							Optional[Any]							=					"Speech2Text2Tokenizer"






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






   def __call__(	self   :       List[Any]						,					*UpperCamelCase_   :       Dict						,					**UpperCamelCase_   :       Optional[int]     )->			str:
     # For backward compatibility
     if self._in_target_context_manager:
       return self.current_processor(*UpperCamelCase_						,					**UpperCamelCase_     )

     if "raw_speech" in kwargs:
       warnings.warn('Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead.'     )
       _lowercase: Tuple						     =    kwargs.pop('raw_speech'     )
     else:
       _lowercase: Optional[Any]						     =    kwargs.pop('audio'						,					UpperCamelCase_     )
     _lowercase: int						     =    kwargs.pop('sampling_rate'						,					UpperCamelCase_     )
     _lowercase: Dict						     =    kwargs.pop('text'						,					UpperCamelCase_     )
     if len(UpperCamelCase_     ) > 0:
       _lowercase: List[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: Optional[int]						     =    self.feature_extractor(UpperCamelCase_						,					*UpperCamelCase_						,					sampling_rate=UpperCamelCase_						,					**UpperCamelCase_     )
     if text is not None:
       _lowercase: str						     =    self.tokenizer(UpperCamelCase_						,					**UpperCamelCase_     )

     if text is None:
       return inputs
     elif audio is None:
       return encodings
     else:
       _lowercase: int						     =    encodings['input_ids']
       return inputs






   def  _a						(	self   :       Optional[int]						,					*UpperCamelCase_   :       Tuple						,					**UpperCamelCase_   :       Dict     )->			List[str]:
     return self.tokenizer.batch_decode(*UpperCamelCase_						,					**UpperCamelCase_     )






   def  _a						(	self   :       Tuple						,					*UpperCamelCase_   :       List[Any]						,					**UpperCamelCase_   :       Union[str, Any]     )->			Optional[int]:
     return self.tokenizer.decode(*UpperCamelCase_						,					**UpperCamelCase_     )






   @contextmanager
   def  _a						(	self   :       Tuple     )->			Union[str, Any]:
     warnings.warn(
         '`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '
         'labels by using the argument `text` of the regular `__call__` method (either in the same call as '
         'your audio inputs, or in a separate call.'     )
     _lowercase: Any						     =    True
     _lowercase: Optional[Any]						     =    self.tokenizer
     yield
     _lowercase: Union[str, Any]						     =    self.feature_extractor
     _lowercase: str						     =    False
