
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


UpperCAmelCase          =							{'configuration_visual_bert': ['VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VisualBertConfig']}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCAmelCase          =							[
					    'VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'VisualBertForMultipleChoice',
					    'VisualBertForPreTraining',
					    'VisualBertForQuestionAnswering',
					    'VisualBertForRegionToPhraseAlignment',
					    'VisualBertForVisualReasoning',
					    'VisualBertLayer',
					    'VisualBertModel',
					    'VisualBertPreTrainedModel',
					]


if TYPE_CHECKING:
					from .configuration_visual_bert import VISUAL_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, VisualBertConfig

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_visual_bert import (
										    VISUAL_BERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    VisualBertForMultipleChoice,
										    VisualBertForPreTraining,
										    VisualBertForQuestionAnswering,
										    VisualBertForRegionToPhraseAlignment,
										    VisualBertForVisualReasoning,
										    VisualBertLayer,
										    VisualBertModel,
										    VisualBertPreTrainedModel,
										)


else:
					import sys

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




"""simple docstring"""






import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin



class  lowercase				(   lowercase__		):
			lowercase			     =    '''AutoFeatureExtractor'''
			lowercase			     =    '''Speech2Text2Tokenizer'''






			def __init__(self     :  Tuple			,SCREAMING_SNAKE_CASE_     :  Union[str, Any]			,SCREAMING_SNAKE_CASE_     :  Optional[int] )					->  int:





				"""simple docstring"""


				super().__init__(SCREAMING_SNAKE_CASE_			,SCREAMING_SNAKE_CASE_ )
				lowerCAmelCase				       =     self.feature_extractor
				lowerCAmelCase				       =     False






			def __call__(self     :  Tuple			,*SCREAMING_SNAKE_CASE_     :  Optional[Any]			,**SCREAMING_SNAKE_CASE_     :  Dict )					->  Any:





				"""simple docstring"""


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

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

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






			def 				UpperCAmelCase       (self     :  Optional[int]			,*SCREAMING_SNAKE_CASE_     :  Any			,**SCREAMING_SNAKE_CASE_     :  List[Any] )					->  str:





				"""simple docstring"""


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






			def 				UpperCAmelCase       (self     :  Optional[int]			,*SCREAMING_SNAKE_CASE_     :  int			,**SCREAMING_SNAKE_CASE_     :  Any )					->  Dict:





				"""simple docstring"""


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






			@contextmanager
			def 				UpperCAmelCase       (self     :  Optional[int] )					->  Union[str, Any]:





				"""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.''' )
				lowerCAmelCase				       =     True
				lowerCAmelCase				       =     self.tokenizer
				yield
				lowerCAmelCase				       =     self.feature_extractor
				lowerCAmelCase				       =     False


