
import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin

class   __snake_case				(			SCREAMING_SNAKE_CASE__   ):






    '''simple docstring'''
    _lowerCAmelCase     =	["""image_processor""", """tokenizer"""]
    _lowerCAmelCase     =	"""AutoImageProcessor"""
    _lowerCAmelCase     =	"""AutoTokenizer"""





    def __init__(   self						:		Optional[int]			,						snake_case						:		str=None			,						snake_case						:		Dict=None			,						**snake_case						:		int							):

      """simple docstring"""





      __lowerCAmelCase			=				None
      if "feature_extractor" in kwargs:
        warnings.warn(
            '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
            ''' instead.'''			,						snake_case			,						)
        __lowerCAmelCase			=				kwargs.pop('''feature_extractor'''							)

      __lowerCAmelCase			=				image_processor if image_processor is not None else feature_extractor
      if image_processor is None:
        raise ValueError('''You need to specify an `image_processor`.'''							)
      if tokenizer is None:
        raise ValueError('''You need to specify a `tokenizer`.'''							)

      super().__init__(snake_case			,						snake_case							)
      __lowerCAmelCase			=				self.image_processor
      __lowerCAmelCase			=				False





    def __call__(   self						:		int			,						*snake_case						:		str			,						**snake_case						:		Tuple							):

      """simple docstring"""





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

      __lowerCAmelCase			=				kwargs.pop('''images'''			,						snake_case							)
      __lowerCAmelCase			=				kwargs.pop('''text'''			,						snake_case							)
      if len(snake_case							) > 0:
        __lowerCAmelCase			=				args[0]
        __lowerCAmelCase			=				args[1:]

      if images is None and text is None:
        raise ValueError('''You need to specify either an `images` or `text` input to process.'''							)

      if images is not None:
        __lowerCAmelCase			=				self.image_processor(snake_case			,						*snake_case			,						**snake_case							)
      if text is not None:
        __lowerCAmelCase			=				self.tokenizer(snake_case			,						**snake_case							)

      if text is None:
        return inputs
      elif images is None:
        return encodings
      else:
        __lowerCAmelCase			=				encodings['''input_ids''']
        return inputs





    def 	A		(   self						:		Dict			,						*snake_case						:		Union[str, Any]			,						**snake_case						:		Tuple							):

      """simple docstring"""





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





    def 	A		(   self						:		List[Any]			,						*snake_case						:		Dict			,						**snake_case						:		Optional[int]							):

      """simple docstring"""





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





    @contextmanager
    def 	A		(   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 images inputs, or in a separate call.'''							)
      __lowerCAmelCase			=				True
      __lowerCAmelCase			=				self.tokenizer
      yield
      __lowerCAmelCase			=				self.image_processor
      __lowerCAmelCase			=				False





    @property
    def 	A		(   self						:		Any							):

      """simple docstring"""





      warnings.warn(
          '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''			,						snake_case			,						)
      return self.image_processor_class





    @property
    def 	A		(   self						:		Tuple							):

      """simple docstring"""





      warnings.warn(
          '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'''			,						snake_case			,						)
      return self.image_processor







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_speech_available,
    is_torch_available,
)


__lowercase													=			{
    """configuration_speech_to_text_2""": ["""SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Speech2Text2Config"""],
    """processing_speech_to_text_2""": ["""Speech2Text2Processor"""],
    """tokenization_speech_to_text_2""": ["""Speech2Text2Tokenizer"""],
}


try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      __lowercase													=			[
          """SPEECH_TO_TEXT_2_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """Speech2Text2ForCausalLM""",
          """Speech2Text2PreTrainedModel""",
      ]


if TYPE_CHECKING:
      from .configuration_speech_to_text_a import SPEECH_TO_TEXT_2_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextaConfig
      from .processing_speech_to_text_a import SpeechaTextaProcessor
      from .tokenization_speech_to_text_a import SpeechaTextaTokenizer

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_speech_to_text_a import (
                SPEECH_TO_TEXT_2_PRETRAINED_MODEL_ARCHIVE_LIST,
                SpeechaTextaForCausalLM,
                SpeechaTextaPreTrainedModel,
            )

else:
      import sys

      __lowercase													=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
