





'''simple docstring'''






import warnings
from contextlib import contextmanager

from ....processing_utils import ProcessorMixin
class 		lowerCamelCase  (      _A       ):
	snake_case_      =   "MCTCTFeatureExtractor"
	snake_case_      =   "AutoTokenizer"



	def __init__(   self		,      a_		,      a_	):
			super().__init__(a_		,      a_	)
			lowerCAmelCase     :    List[str]						=   self.feature_extractor
			lowerCAmelCase     :    Any						=   False



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

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

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



	def   _lowerCamelCase    (   self		,      *a_		,      **a_	):
			return self.tokenizer.batch_decode(*a_		,      **a_	)



	def   _lowerCamelCase    (   self		,      *a_		,      **a_	):
			# For backward compatibility
			if self._in_target_context_manager:
					return self.current_processor.pad(*a_		,      **a_	)

			lowerCAmelCase     :    Optional[Any]						=   kwargs.pop("input_features"		,      a_	)
			lowerCAmelCase     :    Optional[int]						=   kwargs.pop("labels"		,      a_	)
			if len(a_	) > 0:
					lowerCAmelCase     :    Tuple						=   args[0]
					lowerCAmelCase     :    List[Any]						=   args[1:]

			if input_features is not None:
					lowerCAmelCase     :    str						=   self.feature_extractor.pad(a_		,      *a_		,      **a_	)
			if labels is not None:
					lowerCAmelCase     :    int						=   self.tokenizer.pad(a_		,      **a_	)

			if labels is None:
					return input_features
			elif input_features is None:
					return labels
			else:
					lowerCAmelCase     :    Tuple						=   labels["input_ids"]
					return input_features



	def   _lowerCamelCase    (   self		,      *a_		,      **a_	):
			return self.tokenizer.decode(*a_		,      **a_	)





	@contextmanager
	def   _lowerCamelCase    (   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."	)
			lowerCAmelCase     :    Optional[int]						=   True
			lowerCAmelCase     :    int						=   self.tokenizer
			yield
			lowerCAmelCase     :    Any						=   self.feature_extractor
			lowerCAmelCase     :    List[Any]						=   False










'''simple docstring'''






import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class 		lowerCamelCase  (      _A       ):
	snake_case_      =   ["image_processor", "tokenizer"]
	snake_case_      =   "ChineseCLIPImageProcessor"
	snake_case_      =   ("BertTokenizer", "BertTokenizerFast")



	def __init__(   self		,      a_=None		,      a_=None		,      **a_	):
			lowerCAmelCase     :    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."		,      a_		,      )
					lowerCAmelCase     :    Optional[Any]						=   kwargs.pop("feature_extractor"	)

			lowerCAmelCase     :    int						=   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__(a_		,      a_	)
			lowerCAmelCase     :    Dict						=   self.image_processor



	def __call__(   self		,      a_=None		,      a_=None		,      a_=None		,      **a_	):

			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:
					lowerCAmelCase     :    List[str]						=   self.tokenizer(a_		,      return_tensors=a_		,      **a_	)

			if images is not None:
					lowerCAmelCase     :    List[Any]						=   self.image_processor(a_		,      return_tensors=a_		,      **a_	)

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



	def   _lowerCamelCase    (   self		,      *a_		,      **a_	):
			return self.tokenizer.batch_decode(*a_		,      **a_	)



	def   _lowerCamelCase    (   self		,      *a_		,      **a_	):
			return self.tokenizer.decode(*a_		,      **a_	)



	@property
	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    str						=   self.tokenizer.model_input_names
			lowerCAmelCase     :    List[Any]						=   self.image_processor.model_input_names
			return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names	)	)





	@property
	def   _lowerCamelCase    (   self	):
			warnings.warn(
			    "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."		,      a_		,      )
			return self.image_processor_class



