




import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
class 		UpperCAmelCase   (				a_			):







						'''simple docstring'''





						lowerCAmelCase_     		=   '''Speech2TextFeatureExtractor'''
						lowerCAmelCase_     		=   '''Speech2TextTokenizer'''






						def __init__(						self							:     Dict       ,	__lowercase							:     Optional[Any]       ,	__lowercase							:     int						):






							"""simple docstring"""






							super().__init__(lowercase_       ,	lowercase_						)
							snake_case_		    =     self.feature_extractor
							snake_case_		    =     False






						def __call__(						self							:     Union[str, Any]       ,	*__lowercase							:     Any       ,	**__lowercase							:     Any						):






							"""simple docstring"""






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

							if "raw_speech" in kwargs:
								warnings.warn("Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."						)
								snake_case_		    =     kwargs.pop("raw_speech"						)
							else:
								snake_case_		    =     kwargs.pop("audio"       ,	lowercase_						)
							snake_case_		    =     kwargs.pop("sampling_rate"       ,	lowercase_						)
							snake_case_		    =     kwargs.pop("text"       ,	lowercase_						)
							if len(lowercase_						) > 0:
								snake_case_		    =     args[0]
								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:
								snake_case_		    =     self.feature_extractor(lowercase_       ,	*lowercase_       ,	sampling_rate=lowercase_       ,	**lowercase_						)
							if text is not None:
								snake_case_		    =     self.tokenizer(lowercase_       ,	**lowercase_						)

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






						def        snake_case__						(						self							:     List[Any]       ,	*__lowercase							:     Dict       ,	**__lowercase							:     Any						):






							"""simple docstring"""






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






						def        snake_case__						(						self							:     Dict       ,	*__lowercase							:     Optional[int]       ,	**__lowercase							:     Union[str, Any]						):






							"""simple docstring"""






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






						@contextmanager
						def        snake_case__						(						self							:     Tuple						):






							"""simple docstring"""






							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."						)
							snake_case_		    =     True
							snake_case_		    =     self.tokenizer
							yield
							snake_case_		    =     self.feature_extractor
							snake_case_		    =     False



"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


__UpperCamelCase  :      Optional[Any]							      =		{
    '''configuration_rag''': ['''RagConfig'''],
    '''retrieval_rag''': ['''RagRetriever'''],
    '''tokenization_rag''': ['''RagTokenizer'''],
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__UpperCamelCase  :      Tuple							      =		[
							    '''RagModel''',
							    '''RagPreTrainedModel''',
							    '''RagSequenceForGeneration''',
							    '''RagTokenForGeneration''',
							]

try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							__UpperCamelCase  :      Union[str, Any]							      =		[
							    '''TFRagModel''',
							    '''TFRagPreTrainedModel''',
							    '''TFRagSequenceForGeneration''',
							    '''TFRagTokenForGeneration''',
							]


if TYPE_CHECKING:
							from .configuration_rag import RagConfig
							from .retrieval_rag import RagRetriever
							from .tokenization_rag import RagTokenizer

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_rag import RagModel, RagPreTrainedModel, RagSequenceForGeneration, RagTokenForGeneration

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_rag import (
														    TFRagModel,
														    TFRagPreTrainedModel,
														    TFRagSequenceForGeneration,
														    TFRagTokenForGeneration,
														)

else:
							import sys

							__UpperCamelCase  :      Dict							      =		_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)




