





import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin




class  __UpperCamelCase						(       A__						):
     __A  :     Optional[int]            =      """AutoFeatureExtractor"""
     __A  :     Tuple            =      """Speech2Text2Tokenizer"""





     def __init__(    self							,       _UpperCamelCase							,       _UpperCamelCase				):
        super().__init__(_UpperCamelCase							,       _UpperCamelCase				)
        _UpperCAmelCase											=      self.feature_extractor
        _UpperCAmelCase											=      False





     def __call__(    self							,       *_UpperCamelCase							,       **_UpperCamelCase				):
        # For backward compatibility
        if self._in_target_context_manager:
           return self.current_processor(*_UpperCamelCase							,       **_UpperCamelCase				)

        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'''							,       _UpperCamelCase				)
        _UpperCAmelCase											=      kwargs.pop('''sampling_rate'''							,       _UpperCamelCase				)
        _UpperCAmelCase											=      kwargs.pop('''text'''							,       _UpperCamelCase				)
        if len(_UpperCamelCase				) > 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(_UpperCamelCase							,       *_UpperCamelCase							,       sampling_rate=_UpperCamelCase							,       **_UpperCamelCase				)
        if text is not None:
           _UpperCAmelCase											=      self.tokenizer(_UpperCamelCase							,       **_UpperCamelCase				)

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





     def 		UpperCamelCase(    self							,       *_UpperCamelCase							,       **_UpperCamelCase				):
        return self.tokenizer.batch_decode(*_UpperCamelCase							,       **_UpperCamelCase				)





     def 		UpperCamelCase(    self							,       *_UpperCamelCase							,       **_UpperCamelCase				):
        return self.tokenizer.decode(*_UpperCamelCase							,       **_UpperCamelCase				)





     @contextmanager
     def 		UpperCamelCase(    self				):
        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

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


UpperCAmelCase_											=  {
    "configuration_oneformer": ["ONEFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "OneFormerConfig"],
    "processing_oneformer": ["OneFormerProcessor"],
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase_											=  ["OneFormerImageProcessor"]

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   UpperCAmelCase_											=  [
       "ONEFORMER_PRETRAINED_MODEL_ARCHIVE_LIST",
       "OneFormerForUniversalSegmentation",
       "OneFormerModel",
       "OneFormerPreTrainedModel",
   ]

if TYPE_CHECKING:
   from .configuration_oneformer import ONEFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, OneFormerConfig
   from .processing_oneformer import OneFormerProcessor

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .image_processing_oneformer import OneFormerImageProcessor
   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_oneformer import (
          ONEFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
          OneFormerForUniversalSegmentation,
          OneFormerModel,
          OneFormerPreTrainedModel,
      )


else:
   import sys

   UpperCAmelCase_											=  _LazyModule(__name__, globals()["__file__"], _import_structure)