
import warnings
from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType


class     lowercase (		__SCREAMING_SNAKE_CASE       ):
		__lowercase	:	Dict     					=    ["image_processor", "tokenizer"]
		__lowercase	:	List[str]     					=    "FlavaImageProcessor"
		__lowercase	:	Dict     					=    ("BertTokenizer", "BertTokenizerFast")



		def __init__(			self    ,  A_=None    ,  A_=None    ,  **A_	)  -> Tuple:
				"""simple docstring"""
				UpperCamelCase          =					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          =					kwargs.pop('feature_extractor'	)

				UpperCamelCase          =					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          =					self.image_processor



		def __call__(			self    ,  A_ = None    ,  A_ = None    ,  A_ = True    ,  A_ = False    ,  A_ = False    ,  A_ = None    ,  A_ = 0    ,  A_ = None    ,  A_ = None    ,  A_ = None    ,  A_ = None    ,  A_ = None    ,  A_ = False    ,  A_ = False    ,  A_ = False    ,  A_ = False    ,  A_ = True    ,  A_ = None    ,  **A_    ,  )  -> Optional[Any]:
				"""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:
						UpperCamelCase          =					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    ,  )
				if images is not None:
						UpperCamelCase          =					self.image_processor(
						    __UpperCAmelCase    ,  return_image_mask=__UpperCAmelCase    ,  return_codebook_pixels=__UpperCAmelCase    ,  return_tensors=__UpperCAmelCase    ,  **__UpperCAmelCase    ,  )

				if text is not None and images is not None:
						encoding.update(__UpperCAmelCase	)
						return encoding
				elif text is not None:
						return encoding
				else:
						return BatchEncoding(data=dict(**__UpperCAmelCase	)    ,  tensor_type=__UpperCAmelCase	)



		def __UpperCamelCase			(			self    ,  *A_    ,  **A_	)  -> int:
				"""simple docstring"""
				return self.tokenizer.batch_decode(*__UpperCAmelCase    ,  **__UpperCAmelCase	)



		def __UpperCamelCase			(			self    ,  *A_    ,  **A_	)  -> Tuple:
				"""simple docstring"""
				return self.tokenizer.decode(*__UpperCAmelCase    ,  **__UpperCAmelCase	)



		@property
		def __UpperCamelCase			(			self	)  -> List[Any]:
				"""simple docstring"""
				UpperCamelCase          =					self.tokenizer.model_input_names
				UpperCamelCase          =					self.image_processor.model_input_names
				return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names	)	)



		@property
		def __UpperCamelCase			(			self	)  -> List[str]:
				"""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 __UpperCamelCase			(			self	)  -> int:
				"""simple docstring"""
				warnings.warn(
				    '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'    ,  __UpperCAmelCase    ,  )
				return self.image_processor


from ...utils import (
    OptionalDependencyNotAvailable,
    is_torch_available,
    is_transformers_available,
    is_transformers_version,
)


try:
					if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.25.0")):
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					from ...utils.dummy_torch_and_transformers_objects import UnCLIPImageVariationPipeline, UnCLIPPipeline
else:
					from .pipeline_unclip import UnCLIPPipeline
					from .pipeline_unclip_image_variation import UnCLIPImageVariationPipeline
					from .text_proj import UnCLIPTextProjModel
