
"""simple docstring"""


import warnings

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




class    __lowerCamelCase     (   lowerCAmelCase ):
				a__:			str									=						['image_processor', 'tokenizer']
				a__:			Tuple									=						'AutoImageProcessor'
				a__:			Optional[Any]									=						'AutoTokenizer'




				def __init__(							self       ,	UpperCAmelCase=None       ,	UpperCAmelCase=None       ,	**UpperCAmelCase      ):
							lowerCamelCase_ 		=     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       ,	)
										lowerCamelCase_ 		=     kwargs.pop('''feature_extractor'''      )

							lowerCamelCase_ 		=     image_processor if image_processor is not None else feature_extractor
							if image_processor is None:
										raise ValueError('''You have to specify an image_processor.'''      )
							if tokenizer is None:
										raise ValueError('''You have to specify a tokenizer.'''      )

							super().__init__(UpperCAmelCase       ,	UpperCAmelCase      )
							lowerCamelCase_ 		=     self.image_processor




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

							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_ 		=     self.tokenizer(UpperCAmelCase       ,	return_tensors=UpperCAmelCase       ,	**UpperCAmelCase      )

							if images is not None:
										lowerCamelCase_ 		=     self.image_processor(UpperCAmelCase       ,	return_tensors=UpperCAmelCase       ,	**UpperCAmelCase      )

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




				def 					UpperCAmelCase__	(							self       ,	*UpperCAmelCase       ,	**UpperCAmelCase      ):
							return self.tokenizer.batch_decode(*UpperCAmelCase       ,	**UpperCAmelCase      )




				def 					UpperCAmelCase__	(							self       ,	*UpperCAmelCase       ,	**UpperCAmelCase      ):
							return self.tokenizer.decode(*UpperCAmelCase       ,	**UpperCAmelCase      )




				@property
				def 					UpperCAmelCase__	(							self      ):
							lowerCamelCase_ 		=     self.tokenizer.model_input_names
							lowerCamelCase_ 		=     self.image_processor.model_input_names
							return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names      )      )




				@property
				def 					UpperCAmelCase__	(							self      ):
							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      ):
							warnings.warn(
							    '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'''       ,	UpperCAmelCase       ,	)
							return self.image_processor





"""simple docstring"""


import copy

from transformers.configuration_utils import PretrainedConfig
from transformers.utils import logging


A_						       =				logging.get_logger(__name__)




class    __lowerCamelCase     (   lowerCAmelCase ):
				a__:			List[str]									=						'hybrid-clip'
				a__:			List[Any]									=						True




				def __init__(							self       ,	UpperCAmelCase=512       ,	**UpperCAmelCase      ):
							super().__init__(**UpperCAmelCase      )

							if "text_config" not in kwargs:
										raise ValueError('''`text_config` can not be `None`.'''      )

							if "vision_config" not in kwargs:
										raise ValueError('''`vision_config` can not be `None`.'''      )

							lowerCamelCase_ 		=     kwargs.pop('''text_config'''      )
							lowerCamelCase_ 		=     kwargs.pop('''vision_config'''      )

							lowerCamelCase_ 		=     text_config.pop('''model_type'''      )
							lowerCamelCase_ 		=     vision_config.pop('''model_type'''      )

							from transformers import AutoConfig

							lowerCamelCase_ 		=     AutoConfig.for_model(UpperCAmelCase       ,	**UpperCAmelCase      )

							if vision_model_type == "clip":
										lowerCamelCase_ 		=     AutoConfig.for_model(UpperCAmelCase       ,	**UpperCAmelCase      ).vision_config
							elif vision_model_type == "clip_vision_model":
										from transformers import CLIPVisionConfig

										lowerCamelCase_ 		=     CLIPVisionConfig(**UpperCAmelCase      )
							else:
										lowerCamelCase_ 		=     AutoConfig.for_model(UpperCAmelCase       ,	**UpperCAmelCase      )

							lowerCamelCase_ 		=     projection_dim
							lowerCamelCase_ 		=     1.0




				@classmethod
				def 					UpperCAmelCase__	(							cls       ,	UpperCAmelCase       ,	UpperCAmelCase       ,	**UpperCAmelCase      ):
							return cls(text_config=text_config.to_dict()       ,	vision_config=vision_config.to_dict()       ,	**UpperCAmelCase      )





				def 					UpperCAmelCase__	(							self      ):
							lowerCamelCase_ 		=     copy.deepcopy(self.__dict__      )
							lowerCamelCase_ 		=     self.text_config.to_dict()
							lowerCamelCase_ 		=     self.vision_config.to_dict()
							lowerCamelCase_ 		=     self.__class__.model_type
							return output



