




"""simple docstring"""

import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
class 			lowerCamelCase__    (  __UpperCAmelCase			):
			a__ :      Tuple								=     """AutoFeatureExtractor"""
			a__ :      Any								=     """Speech2Text2Tokenizer"""


			def __init__(     self				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







					super().__init__(lowercase_				, lowercase_							)
					snake_case		:						Any								=				self.feature_extractor
					snake_case		:						Optional[int]								=				False


			def __call__(     self				, *SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







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

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

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


			def 							lowerCamelCase_				(     self				, *SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







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


			def 							lowerCamelCase_				(     self				, *SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







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



			@contextmanager
			def 							lowerCamelCase_				(     self							):



					"""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."							)
					snake_case		:						Union[str, Any]								=				True
					snake_case		:						Dict								=				self.tokenizer
					yield
					snake_case		:						Optional[int]								=				self.feature_extractor
					snake_case		:						List[str]								=				False










"""simple docstring"""

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class 			lowerCamelCase__    (  lowerCamelCase_			):
			a__ :      Tuple								=     ["""image_processor""", """tokenizer"""]
			a__ :      List[Any]								=     """EfficientNetImageProcessor"""
			a__ :      str								=     ("""BertTokenizer""", """BertTokenizerFast""")


			def __init__(     self				, SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







					super().__init__(SCREAMING_SNAKE_CASE				, SCREAMING_SNAKE_CASE							)


			def __call__(     self				, SCREAMING_SNAKE_CASE=None				, SCREAMING_SNAKE_CASE=None				, SCREAMING_SNAKE_CASE="max_length"				, SCREAMING_SNAKE_CASE=64				, SCREAMING_SNAKE_CASE=None				, **SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







					if text is None and images is None:
							raise ValueError("You have to specify either text or images. Both cannot be none."							)

					if text is not None:
							snake_case		:						Dict								=				self.tokenizer(
							    SCREAMING_SNAKE_CASE				, padding=SCREAMING_SNAKE_CASE				, max_length=SCREAMING_SNAKE_CASE				, return_tensors=SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							)

					if images is not None:
							snake_case		:						Tuple								=				self.image_processor(SCREAMING_SNAKE_CASE				, return_tensors=SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							)

					if text is not None and images is not None:
							snake_case		:						Dict								=				image_features.pixel_values
							return encoding
					elif text is not None:
							return encoding
					else:
							return BatchEncoding(data=dict(**SCREAMING_SNAKE_CASE							)				, tensor_type=SCREAMING_SNAKE_CASE							)


			def 							lowerCamelCase_				(     self				, *SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







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


			def 							lowerCamelCase_				(     self				, *SCREAMING_SNAKE_CASE				, **SCREAMING_SNAKE_CASE							):



					"""simple docstring"""







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



			@property
			def 							lowerCamelCase_				(     self							):



					"""simple docstring"""







					snake_case		:						Optional[Any]								=				self.tokenizer.model_input_names
					snake_case		:						Any								=				self.image_processor.model_input_names
					return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)

