
'''simple docstring'''
import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin


class        SCREAMING_SNAKE_CASE__	(			snake_case_):
				lowerCAmelCase_			       =				"""AutoFeatureExtractor"""
				lowerCAmelCase_			       =				"""Speech2Text2Tokenizer"""







				def __init__(    self		,							A_		,							A_			)->						Dict:







											'''simple docstring'''






											super().__init__(A_		,							A_			)
											UpperCamelCase					       =			self.feature_extractor
											UpperCamelCase					       =			False







				def __call__(    self		,							*A_		,							**A_			)->						Optional[int]:







											'''simple docstring'''






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

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

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







				def 		UpperCAmelCase_  (    self		,							*A_		,							**A_			)->						List[Any]:







											'''simple docstring'''






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







				def 		UpperCAmelCase_  (    self		,							*A_		,							**A_			)->						Optional[int]:







											'''simple docstring'''






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







				@contextmanager
				def 		UpperCAmelCase_  (    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					       =			True
											UpperCamelCase					       =			self.tokenizer
											yield
											UpperCamelCase					       =			self.feature_extractor
											UpperCamelCase					       =			False





from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available


lowerCamelCase__   = {
    '''configuration_ernie_m''': ['''ERNIE_M_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ErnieMConfig'''],
}

try:
   if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowerCamelCase__   = ['''ErnieMTokenizer''']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowerCamelCase__   = [
       '''ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''ErnieMForMultipleChoice''',
       '''ErnieMForQuestionAnswering''',
       '''ErnieMForSequenceClassification''',
       '''ErnieMForTokenClassification''',
       '''ErnieMModel''',
       '''ErnieMPreTrainedModel''',
       '''ErnieMForInformationExtraction''',
   ]


if TYPE_CHECKING:
   from .configuration_ernie_m import ERNIE_M_PRETRAINED_CONFIG_ARCHIVE_MAP, ErnieMConfig

   try:
      if not is_sentencepiece_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_ernie_m import ErnieMTokenizer

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_ernie_m import (
          ERNIE_M_PRETRAINED_MODEL_ARCHIVE_LIST,
          ErnieMForInformationExtraction,
          ErnieMForMultipleChoice,
          ErnieMForQuestionAnswering,
          ErnieMForSequenceClassification,
          ErnieMForTokenClassification,
          ErnieMModel,
          ErnieMPreTrainedModel,
      )


else:
   import sys

   lowerCamelCase__   = _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)




