






# Lint as: python3
import dataclasses
import re
from dataclasses import dataclass
from functools import total_ordering
from typing import Optional, Union


SCREAMING_SNAKE_CASE__   :      List[str]				=		re.compile(r"""^(?P<major>\d+)""" r"""\.(?P<minor>\d+)""" r"""\.(?P<patch>\d+)$""")
@total_ordering
@dataclass
class     lowerCamelCase_					:
				a__       							=	42
				a__       							=	None
				a__       							=	None
				a__       							=	None
				a__       							=	None







				def       A						(    self  ):
								"""simple docstring"""
								__magic_name__  ,					__magic_name__  ,					__magic_name__		:Tuple   =   _str_to_version_tuple(self.version_str  )







				def __repr__(    self  ):
								"""simple docstring"""
								return F'''{self.tuple[0]}.{self.tuple[1]}.{self.tuple[2]}'''







				@property
				def       A						(    self  ):
								"""simple docstring"""
								return self.major, self.minor, self.patch







				def       A						(    self							,       __lowerCAmelCase  ):
								"""simple docstring"""
								if isinstance(__lowerCAmelCase							,       __lowerCAmelCase  ):
												return Version(__lowerCAmelCase  )
								elif isinstance(__lowerCAmelCase							,       __lowerCAmelCase  ):
												return other
								raise TypeError(F'''{other} (type {type(__lowerCAmelCase  )}) cannot be compared to version.'''  )







				def __eq__(    self							,       __lowerCAmelCase  ):
								"""simple docstring"""
								try:
												__magic_name__		:Union[str, Any]   =   self._validate_operand(__lowerCAmelCase  )
								except (TypeError, ValueError):
												return False
								else:
												return self.tuple == other.tuple







				def __lt__(    self							,       __lowerCAmelCase  ):
								"""simple docstring"""
								__magic_name__		:Union[str, Any]   =   self._validate_operand(__lowerCAmelCase  )
								return self.tuple < other.tuple







				def __hash__(    self  ):
								"""simple docstring"""
								return hash(_version_tuple_to_str(self.tuple  )  )







				@classmethod
				def       A						(    cls							,       __lowerCAmelCase  ):
								"""simple docstring"""
								__magic_name__		:int   =   {f.name for f in dataclasses.fields(cls  )}
								return cls(**{k: v for k, v in dic.items() if k in field_names}  )







				def       A						(    self  ):
								"""simple docstring"""
								return self.version_str







def   __lowercase       (			snake_case			):







				"""simple docstring"""






				__magic_name__		:List[str]   =   _VERSION_REG.match(snake_case			)
				if not res:
								raise ValueError(f'''Invalid version \'{version_str}\'. Format should be x.y.z with {{x,y,z}} being digits.'''			)
				return tuple(int(snake_case			) for v in [res.group('''major'''			), res.group('''minor'''			), res.group('''patch'''			)]			)

def   __lowercase       (			snake_case			):







				"""simple docstring"""






				return ".".join(str(snake_case			) for v in version_tuple			)














import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class     lowerCamelCase_					(   lowerCamelCase			):
				a__       							=	['''image_processor''', '''tokenizer''']
				a__       							=	'''ChineseCLIPImageProcessor'''
				a__       							=	('''BertTokenizer''', '''BertTokenizerFast''')







				def __init__(    self							,       __lowerCAmelCase=None							,       __lowerCAmelCase=None							,       **__lowerCAmelCase  ):
								"""simple docstring"""
								__magic_name__		:Tuple   =   None
								if "feature_extractor" in kwargs:
												warnings.warn(
												    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
												    ''' instead.'''							,       __lowerCAmelCase							,       )
												__magic_name__		:Optional[Any]   =   kwargs.pop('''feature_extractor'''  )

								__magic_name__		: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__(__lowerCAmelCase							,       __lowerCAmelCase  )
								__magic_name__		:List[Any]   =   self.image_processor







				def __call__(    self							,       __lowerCAmelCase=None							,       __lowerCAmelCase=None							,       __lowerCAmelCase=None							,       **__lowerCAmelCase  ):
								"""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:
												__magic_name__		:int   =   self.tokenizer(__lowerCAmelCase							,       return_tensors=__lowerCAmelCase							,       **__lowerCAmelCase  )

								if images is not None:
												__magic_name__		:Dict   =   self.image_processor(__lowerCAmelCase							,       return_tensors=__lowerCAmelCase							,       **__lowerCAmelCase  )

								if text is not None and images is not None:
												__magic_name__		:Union[str, Any]   =   image_features.pixel_values
												return encoding
								elif text is not None:
												return encoding
								else:
												return BatchEncoding(data=dict(**__lowerCAmelCase  )							,       tensor_type=__lowerCAmelCase  )







				def       A						(    self							,       *__lowerCAmelCase							,       **__lowerCAmelCase  ):
								"""simple docstring"""
								return self.tokenizer.batch_decode(*__lowerCAmelCase							,       **__lowerCAmelCase  )







				def       A						(    self							,       *__lowerCAmelCase							,       **__lowerCAmelCase  ):
								"""simple docstring"""
								return self.tokenizer.decode(*__lowerCAmelCase							,       **__lowerCAmelCase  )







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







				@property
				def       A						(    self  ):
								"""simple docstring"""
								warnings.warn(
								    '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''							,       __lowerCAmelCase							,       )
								return self.image_processor_class






