




import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin





class        lowerCamelCase_							(      _SCREAMING_SNAKE_CASE					):


 '''simple docstring'''







 lowercase_				    =    "MCTCTFeatureExtractor"
 lowercase_				    =    "AutoTokenizer"



 def __init__(							self  :		Optional[int]				,				_lowerCAmelCase  :		List[Any]				,				_lowerCAmelCase  :		Optional[Any]						):
       super().__init__(_lowerCAmelCase				,				_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			self.feature_extractor
       SCREAMING_SNAKE_CASE_							=			False



 def __call__(							self  :		Any				,				*_lowerCAmelCase  :		str				,				**_lowerCAmelCase  :		Tuple						):
       # 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.'						)
             SCREAMING_SNAKE_CASE_							=			kwargs.pop('raw_speech'						)
       else:
             SCREAMING_SNAKE_CASE_							=			kwargs.pop('audio'				,				_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			kwargs.pop('sampling_rate'				,				_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			kwargs.pop('text'				,				_lowerCAmelCase						)
       if len(_lowerCAmelCase						) > 0:
             SCREAMING_SNAKE_CASE_							=			args[0]
             SCREAMING_SNAKE_CASE_							=			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:
             SCREAMING_SNAKE_CASE_							=			self.feature_extractor(_lowerCAmelCase				,				*_lowerCAmelCase				,				sampling_rate=_lowerCAmelCase				,				**_lowerCAmelCase						)
       if text is not None:
             SCREAMING_SNAKE_CASE_							=			self.tokenizer(_lowerCAmelCase				,				**_lowerCAmelCase						)

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



 def       lowerCAmelCase_  (							self  :		List[str]				,				*_lowerCAmelCase  :		Optional[Any]				,				**_lowerCAmelCase  :		Optional[int]						):
       return self.tokenizer.batch_decode(*_lowerCAmelCase				,				**_lowerCAmelCase						)



 def       lowerCAmelCase_  (							self  :		Optional[int]				,				*_lowerCAmelCase  :		int				,				**_lowerCAmelCase  :		List[Any]						):
       # For backward compatibility
       if self._in_target_context_manager:
             return self.current_processor.pad(*_lowerCAmelCase				,				**_lowerCAmelCase						)

       SCREAMING_SNAKE_CASE_							=			kwargs.pop('input_features'				,				_lowerCAmelCase						)
       SCREAMING_SNAKE_CASE_							=			kwargs.pop('labels'				,				_lowerCAmelCase						)
       if len(_lowerCAmelCase						) > 0:
             SCREAMING_SNAKE_CASE_							=			args[0]
             SCREAMING_SNAKE_CASE_							=			args[1:]

       if input_features is not None:
             SCREAMING_SNAKE_CASE_							=			self.feature_extractor.pad(_lowerCAmelCase				,				*_lowerCAmelCase				,				**_lowerCAmelCase						)
       if labels is not None:
             SCREAMING_SNAKE_CASE_							=			self.tokenizer.pad(_lowerCAmelCase				,				**_lowerCAmelCase						)

       if labels is None:
             return input_features
       elif input_features is None:
             return labels
       else:
             SCREAMING_SNAKE_CASE_							=			labels['input_ids']
             return input_features



 def       lowerCAmelCase_  (							self  :		Tuple				,				*_lowerCAmelCase  :		Optional[Any]				,				**_lowerCAmelCase  :		List[str]						):
       return self.tokenizer.decode(*_lowerCAmelCase				,				**_lowerCAmelCase						)




 @contextmanager
 def       lowerCAmelCase_  (							self  :		List[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.'						)
       SCREAMING_SNAKE_CASE_							=			True
       SCREAMING_SNAKE_CASE_							=			self.tokenizer
       yield
       SCREAMING_SNAKE_CASE_							=			self.feature_extractor
       SCREAMING_SNAKE_CASE_							=			False





from typing import TYPE_CHECKING

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


lowerCamelCase__ :   str					=							{
    'configuration_mask2former': [
        'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Mask2FormerConfig',
    ],
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowerCamelCase__ :   int					=							['Mask2FormerImageProcessor']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowerCamelCase__ :   Dict					=							[
       'MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST',
       'Mask2FormerForUniversalSegmentation',
       'Mask2FormerModel',
       'Mask2FormerPreTrainedModel',
   ]

if TYPE_CHECKING:
   from .configuration_maskaformer import MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, MaskaFormerConfig

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .image_processing_maskaformer import MaskaFormerImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_maskaformer import (
          MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
          MaskaFormerForUniversalSegmentation,
          MaskaFormerModel,
          MaskaFormerPreTrainedModel,
      )


else:
   import sys

   lowerCamelCase__ :   Tuple					=							_LazyModule(__name__, globals()['__file__'], _import_structure)