

import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin







class       snake_case__  ( lowerCAmelCase_     ):
			SCREAMING_SNAKE_CASE__     				=						'''Speech2TextFeatureExtractor'''
			SCREAMING_SNAKE_CASE__     				=						'''Speech2TextTokenizer'''







			def __init__(			self			: Union[str, Any]			,  lowercase			: str			,  lowercase			: List[Any]  ):





								'''simple docstring'''



								super().__init__(lowercase			,  lowercase  )
								UpperCAmelCase			:   int      =				self.feature_extractor
								UpperCAmelCase			:   int      =				False







			def __call__(			self			: Any			,  *lowercase			: List[Any]			,  **lowercase			: Optional[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."  )
													UpperCAmelCase			:   Dict      =				kwargs.pop("raw_speech"  )
								else:
													UpperCAmelCase			:   Any      =				kwargs.pop("audio"			,  lowercase  )
								UpperCAmelCase			:   Dict      =				kwargs.pop("sampling_rate"			,  lowercase  )
								UpperCAmelCase			:   Optional[Any]      =				kwargs.pop("text"			,  lowercase  )
								if len(lowercase  ) > 0:
													UpperCAmelCase			:   int      =				args[0]
													UpperCAmelCase			:   int      =				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:
													UpperCAmelCase			:   str      =				self.feature_extractor(lowercase			,  *lowercase			,  sampling_rate=lowercase			,  **lowercase  )
								if text is not None:
													UpperCAmelCase			:   str      =				self.tokenizer(lowercase			,  **lowercase  )

								if text is None:
													return inputs
								elif audio is None:
													return encodings
								else:
													UpperCAmelCase			:   Any      =				encodings["input_ids"]
													return inputs







			def 			__lowerCAmelCase				(			self			: Dict			,  *lowercase			: Optional[int]			,  **lowercase			: Dict  ):





								'''simple docstring'''



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







			def 			__lowerCAmelCase				(			self			: Union[str, Any]			,  *lowercase			: Tuple			,  **lowercase			: Any  ):





								'''simple docstring'''



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







			@contextmanager
			def 			__lowerCAmelCase				(			self			: Dict  ):





								'''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."  )
								UpperCAmelCase			:   Dict      =				True
								UpperCAmelCase			:   Optional[Any]      =				self.tokenizer
								yield
								UpperCAmelCase			:   List[Any]      =				self.feature_extractor
								UpperCAmelCase			:   Tuple      =				False





"""simple docstring"""






from typing import TYPE_CHECKING

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


snake_case_   :   Dict        =       {
    """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""],
    """tokenization_mvp""": ["""MvpTokenizer"""],
}

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	snake_case_   :   List[Any]        =       ["""MvpTokenizerFast"""]

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	snake_case_   :   Any        =       [
	    """MVP_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """MvpForCausalLM""",
	    """MvpForConditionalGeneration""",
	    """MvpForQuestionAnswering""",
	    """MvpForSequenceClassification""",
	    """MvpModel""",
	    """MvpPreTrainedModel""",
	]

if TYPE_CHECKING:
	from .configuration_mvp import MVP_PRETRAINED_CONFIG_ARCHIVE_MAP, MvpConfig, MvpOnnxConfig
	from .tokenization_mvp import MvpTokenizer

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_mvp_fast import MvpTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_mvp import (
		    MVP_PRETRAINED_MODEL_ARCHIVE_LIST,
		    MvpForCausalLM,
		    MvpForConditionalGeneration,
		    MvpForQuestionAnswering,
		    MvpForSequenceClassification,
		    MvpModel,
		    MvpPreTrainedModel,
		)

else:
	import sys

	snake_case_   :   List[str]        =       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


