



import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin







class       _snake_case				(     __snake_case ):






   '''simple docstring'''






   A__      : Union[str, Any]       =						"AutoFeatureExtractor"
   A__      : List[str]       =						"Speech2Text2Tokenizer"


   def __init__(    self:     Optional[Any]  ,lowerCamelCase_:     int  ,lowerCamelCase_:     Dict							)	->      str:
       super().__init__(lowerCamelCase_  ,lowerCamelCase_							)
       UpperCAmelCase_     :       Tuple  		=					self.feature_extractor
       UpperCAmelCase_     :       Dict  		=					False


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

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

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


   def       A__    (    self:     Optional[int]  ,*lowerCamelCase_:     List[str]  ,**lowerCamelCase_:     Union[str, Any]							)	->      Optional[Any]:
       return self.tokenizer.batch_decode(*lowerCamelCase_  ,**lowerCamelCase_							)


   def       A__    (    self:     str  ,*lowerCamelCase_:     Any  ,**lowerCamelCase_:     List[Any]							)	->      List[str]:
       return self.tokenizer.decode(*lowerCamelCase_  ,**lowerCamelCase_							)






   @contextmanager
   def       A__    (    self:     Dict							)	->      Optional[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."""							)
       UpperCAmelCase_     :       int  		=					True
       UpperCAmelCase_     :       Tuple  		=					self.tokenizer
       yield
       UpperCAmelCase_     :       Tuple  		=					self.feature_extractor
       UpperCAmelCase_     :       Dict  		=					False




from typing import TYPE_CHECKING

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


__UpperCAmelCase			:			int			      =					{"configuration_vilt": ["VILT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViltConfig"]}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCAmelCase			:			Optional[Any]			      =					["ViltFeatureExtractor"]
  __UpperCAmelCase			:			Union[str, Any]			      =					["ViltImageProcessor"]
  __UpperCAmelCase			:			Dict			      =					["ViltProcessor"]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __UpperCAmelCase			:			List[Any]			      =					[
      "VILT_PRETRAINED_MODEL_ARCHIVE_LIST",
      "ViltForImageAndTextRetrieval",
      "ViltForImagesAndTextClassification",
      "ViltForTokenClassification",
      "ViltForMaskedLM",
      "ViltForQuestionAnswering",
      "ViltLayer",
      "ViltModel",
      "ViltPreTrainedModel",
  ]


if TYPE_CHECKING:
  from .configuration_vilt import VILT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViltConfig

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .feature_extraction_vilt import ViltFeatureExtractor
    from .image_processing_vilt import ViltImageProcessor
    from .processing_vilt import ViltProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_vilt import (
        VILT_PRETRAINED_MODEL_ARCHIVE_LIST,
        ViltForImageAndTextRetrieval,
        ViltForImagesAndTextClassification,
        ViltForMaskedLM,
        ViltForQuestionAnswering,
        ViltForTokenClassification,
        ViltLayer,
        ViltModel,
        ViltPreTrainedModel,
    )


else:
  import sys

  __UpperCAmelCase			:			Any			      =					_LazyModule(__name__, globals()["__file__"], _import_structure)

