






"""simple docstring"""






import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding





class       snake_case_       (    _lowerCamelCase       ):



	"""simple docstring"""

	SCREAMING_SNAKE_CASE_:							Optional[int]   			=					["""image_processor""", """tokenizer"""]
	SCREAMING_SNAKE_CASE_:							Optional[Any]   			=					"""ViTImageProcessor"""
	SCREAMING_SNAKE_CASE_:							List[Any]   			=					("""CLIPTokenizer""", """CLIPTokenizerFast""")


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


					"""simple docstring"""

					A__							 =       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  ,					)
									A__							 =       kwargs.pop('feature_extractor'						)

					A__							 =       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						)


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


					"""simple docstring"""

					if text is None and visual_prompt is None and images is None:
									raise ValueError('You have to specify either text, visual prompt or images.'						)

					if text is not None and visual_prompt is not None:
									raise ValueError('You have to specify exactly one type of prompt. Either text or visual prompt.'						)

					if text is not None:
									A__							 =       self.tokenizer(__a  ,					return_tensors=__a  ,					**__a						)

					if visual_prompt is not None:
									A__							 =       self.image_processor(__a  ,					return_tensors=__a  ,					**__a						)

					if images is not None:
									A__							 =       self.image_processor(__a  ,					return_tensors=__a  ,					**__a						)

					if visual_prompt is not None and images is not None:
									A__							 =       {
									    'pixel_values': image_features.pixel_values,
									    'conditional_pixel_values': prompt_features.pixel_values,
									}
									return encoding
					elif text is not None and images is not None:
									A__							 =       image_features.pixel_values
									return encoding
					elif text is not None:
									return encoding
					elif visual_prompt is not None:
									A__							 =       {
									    'conditional_pixel_values': prompt_features.pixel_values,
									}
									return encoding
					else:
									return BatchEncoding(data=dict(**__a						)  ,					tensor_type=__a						)


	def       _UpperCAmelCase						(      self  ,					*__a  ,					**__a						):


					"""simple docstring"""

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


	def       _UpperCAmelCase						(      self  ,					*__a  ,					**__a						):


					"""simple docstring"""

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


	@property
	def       _UpperCAmelCase						(      self						):


					"""simple docstring"""

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






	@property
	def       _UpperCAmelCase						(      self						):


					"""simple docstring"""

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










"""simple docstring"""






from ...processing_utils import ProcessorMixin





class       snake_case_       (    _lowerCamelCase       ):



	"""simple docstring"""

	SCREAMING_SNAKE_CASE_:							Union[str, Any]   			=					["""image_processor""", """feature_extractor"""]
	SCREAMING_SNAKE_CASE_:							Optional[int]   			=					"""TvltImageProcessor"""
	SCREAMING_SNAKE_CASE_:							Optional[int]   			=					"""TvltFeatureExtractor"""


	def __init__(      self  ,					__a  ,					__a						):


					"""simple docstring"""

					super().__init__(image_processor=__a  ,					feature_extractor=__a						)

					A__							 =       image_processor
					A__							 =       feature_extractor


	def __call__(      self  ,					__a=None  ,					__a=None  ,					__a=None  ,					__a=None  ,					__a=False  ,					__a=False  ,					*__a  ,					**__a  ,					):


					"""simple docstring"""

					if images is None and audio is None:
									raise ValueError('You need to specify either an `images` or `audio` input to process.'						)

					A__							 =       None
					if images is not None:
									A__							 =       self.image_processor(__a  ,					mask_pixel=__a  ,					*__a  ,					**__a						)
					if images_mixed is not None:
									A__							 =       self.image_processor(__a  ,					is_mixed=__a  ,					*__a  ,					**__a						)
					if audio is not None:
									A__							 =       self.feature_extractor(
									    __a  ,					*__a  ,					sampling_rate=__a  ,					mask_audio=__a  ,					**__a						)

					A__							 =       {}
					if audio is not None:
									output_dict.update(__a						)
					if images is not None:
									output_dict.update(__a						)
					if images_mixed_dict is not None:
									output_dict.update(__a						)
					return output_dict






	@property
	def       _UpperCAmelCase						(      self						):


					"""simple docstring"""

					A__							 =       self.image_processor.model_input_names
					A__							 =       self.feature_extractor.model_input_names
					return list(dict.fromkeys(image_processor_input_names + feature_extractor_input_names						)						)


