


'''simple docstring'''
import warnings
from typing import List, Optional, Union

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType
class      lowercase			(							A__      ):

		"""simple docstring"""

		_a									=       ['image_processor', 'tokenizer']
		_a									=       'ViltImageProcessor'
		_a									=       ('BertTokenizer', 'BertTokenizerFast')




		def __init__(	self					,     UpperCamelCase_=None					,     UpperCamelCase_=None					,     **UpperCamelCase_							):

							'''simple docstring'''


							UpperCamelCase__     :Optional[Any]							      =				None
							if "feature_extractor" in kwargs:
												warnings.warn(
												    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
												    ''' instead.'''					,     UpperCamelCase_					,     )
												UpperCamelCase__     :List[str]							      =				kwargs.pop('''feature_extractor'''							)

							UpperCamelCase__     :Tuple							      =				image_processor if image_processor is not None else feature_extractor
							if image_processor is None:
												raise ValueError('''You need to specify an `image_processor`.'''							)
							if tokenizer is None:
												raise ValueError('''You need to specify a `tokenizer`.'''							)

							super().__init__(UpperCamelCase_					,     UpperCamelCase_							)
							UpperCamelCase__     :Optional[int]							      =				self.image_processor




		def __call__(	self					,     UpperCamelCase_					,     UpperCamelCase_ = None					,     UpperCamelCase_ = True					,     UpperCamelCase_ = False					,     UpperCamelCase_ = None					,     UpperCamelCase_ = None					,     UpperCamelCase_ = 0					,     UpperCamelCase_ = None					,     UpperCamelCase_ = None					,     UpperCamelCase_ = None					,     UpperCamelCase_ = False					,     UpperCamelCase_ = False					,     UpperCamelCase_ = False					,     UpperCamelCase_ = False					,     UpperCamelCase_ = True					,     UpperCamelCase_ = None					,     **UpperCamelCase_					,     ):

							'''simple docstring'''


							UpperCamelCase__     :List[str]							      =				self.tokenizer(
							    text=UpperCamelCase_					,     add_special_tokens=UpperCamelCase_					,     padding=UpperCamelCase_					,     truncation=UpperCamelCase_					,     max_length=UpperCamelCase_					,     stride=UpperCamelCase_					,     pad_to_multiple_of=UpperCamelCase_					,     return_token_type_ids=UpperCamelCase_					,     return_attention_mask=UpperCamelCase_					,     return_overflowing_tokens=UpperCamelCase_					,     return_special_tokens_mask=UpperCamelCase_					,     return_offsets_mapping=UpperCamelCase_					,     return_length=UpperCamelCase_					,     verbose=UpperCamelCase_					,     return_tensors=UpperCamelCase_					,     **UpperCamelCase_					,     )
							# add pixel_values + pixel_mask
							UpperCamelCase__     :str							      =				self.image_processor(UpperCamelCase_					,     return_tensors=UpperCamelCase_							)
							encoding.update(UpperCamelCase_							)

							return encoding




		def 					lowerCAmelCase__       (	self					,     *UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


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




		def 					lowerCAmelCase__       (	self					,     *UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


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




		@property
		def 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							UpperCamelCase__     :List[Any]							      =				self.tokenizer.model_input_names
							UpperCamelCase__     :Union[str, Any]							      =				self.image_processor.model_input_names
							return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)




		@property
		def 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							warnings.warn(
							    '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''					,     UpperCamelCase_					,     )
							return self.image_processor_class




		@property
		def 					lowerCAmelCase__       (	self							):

							'''simple docstring'''


							warnings.warn(
							    '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'''					,     UpperCamelCase_					,     )
							return self.image_processor



'''simple docstring'''
import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin
class      lowercase			(							A__      ):

		"""simple docstring"""

		_a									=       'Speech2TextFeatureExtractor'
		_a									=       'Speech2TextTokenizer'




		def __init__(	self					,     UpperCamelCase_					,     UpperCamelCase_							):

							'''simple docstring'''


							super().__init__(UpperCamelCase_					,     UpperCamelCase_							)
							UpperCamelCase__     :List[str]							      =				self.feature_extractor
							UpperCamelCase__     :Optional[Any]							      =				False




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

							'''simple docstring'''


							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__     :Optional[Any]							      =				kwargs.pop('''raw_speech'''							)
							else:
												UpperCamelCase__     :List[Any]							      =				kwargs.pop('''audio'''					,     UpperCamelCase_							)
							UpperCamelCase__     :List[Any]							      =				kwargs.pop('''sampling_rate'''					,     UpperCamelCase_							)
							UpperCamelCase__     :Dict							      =				kwargs.pop('''text'''					,     UpperCamelCase_							)
							if len(UpperCamelCase_							) > 0:
												UpperCamelCase__     :Tuple							      =				args[0]
												UpperCamelCase__     :Optional[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:
												UpperCamelCase__     :Any							      =				self.feature_extractor(UpperCamelCase_					,     *UpperCamelCase_					,     sampling_rate=UpperCamelCase_					,     **UpperCamelCase_							)
							if text is not None:
												UpperCamelCase__     :Dict							      =				self.tokenizer(UpperCamelCase_					,     **UpperCamelCase_							)

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




		def 					lowerCAmelCase__       (	self					,     *UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


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




		def 					lowerCAmelCase__       (	self					,     *UpperCamelCase_					,     **UpperCamelCase_							):

							'''simple docstring'''


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




		@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.'''							)
							UpperCamelCase__     :Optional[Any]							      =				True
							UpperCamelCase__     :Any							      =				self.tokenizer
							yield
							UpperCamelCase__     :Any							      =				self.feature_extractor
							UpperCamelCase__     :Any							      =				False