
'''simple docstring'''



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


UpperCamelCase__      :		str       							=  re.compile(R"^(?P<major>\d+)" R"\.(?P<minor>\d+)" R"\.(?P<patch>\d+)$")

@total_ordering
@dataclass
class    _a				:





       """simple docstring"""




       SCREAMING_SNAKE_CASE      =  42
       SCREAMING_SNAKE_CASE      =  None
       SCREAMING_SNAKE_CASE      =  None
       SCREAMING_SNAKE_CASE      =  None
       SCREAMING_SNAKE_CASE      =  None






       def        UpperCamelCase				(							self      )    ->			Optional[int]:
          _SCREAMING_SNAKE_CASE ,							_SCREAMING_SNAKE_CASE ,							_SCREAMING_SNAKE_CASE      =				_str_to_version_tuple(self.version_str      )






       def __repr__(							self      )    ->			Optional[Any]:
          return F"{self.tuple[0]}.{self.tuple[1]}.{self.tuple[2]}"






       @property
       def        UpperCamelCase				(							self      )    ->			Any:
          return self.major, self.minor, self.patch






       def        UpperCamelCase				(							self       ,							A__      )    ->			Dict:
          if isinstance(A__       ,							A__      ):
             return Version(A__      )
          elif isinstance(A__       ,							A__      ):
             return other
          raise TypeError(F"{other} (type {type(A__      )}) cannot be compared to version."      )






       def __eq__(							self       ,							A__      )    ->			Union[str, Any]:
          try:
             _SCREAMING_SNAKE_CASE      =				self._validate_operand(A__      )
          except (TypeError, ValueError):
             return False
          else:
             return self.tuple == other.tuple






       def __lt__(							self       ,							A__      )    ->			Optional[int]:
          _SCREAMING_SNAKE_CASE      =				self._validate_operand(A__      )
          return self.tuple < other.tuple






       def __hash__(							self      )    ->			List[str]:
          return hash(_version_tuple_to_str(self.tuple      )      )






       @classmethod
       def        UpperCamelCase				(							cls       ,							A__      )    ->			Union[str, Any]:
          _SCREAMING_SNAKE_CASE      =				{f.name for f in dataclasses.fields(cls      )}
          return cls(**{k: v for k, v in dic.items() if k in field_names}      )






       def        UpperCamelCase				(							self      )    ->			str:
          return self.version_str






def    lowerCAmelCase_	(				SCREAMING_SNAKE_CASE_						)     ->     Tuple:




   """simple docstring"""
   _SCREAMING_SNAKE_CASE      =				_VERSION_REG.match(SCREAMING_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(SCREAMING_SNAKE_CASE_						) for v in [res.group("""major"""						), res.group("""minor"""						), res.group("""patch"""						)]						)







def    lowerCAmelCase_	(				SCREAMING_SNAKE_CASE_						)     ->     Tuple:




   """simple docstring"""
   return ".".join(str(SCREAMING_SNAKE_CASE_						) for v in version_tuple						)








'''simple docstring'''



import warnings

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

class    _a				(_lowerCamelCase):





       """simple docstring"""




       SCREAMING_SNAKE_CASE      =  ['image_processor', 'tokenizer']
       SCREAMING_SNAKE_CASE      =  'ChineseCLIPImageProcessor'
       SCREAMING_SNAKE_CASE      =  ('BertTokenizer', 'BertTokenizerFast')






       def __init__(							self       ,							A__=None       ,							A__=None       ,							**A__      )    ->			int:
          _SCREAMING_SNAKE_CASE      =				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__       ,							)
             _SCREAMING_SNAKE_CASE      =				kwargs.pop("""feature_extractor"""      )

          _SCREAMING_SNAKE_CASE      =				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__      )
          _SCREAMING_SNAKE_CASE      =				self.image_processor






       def __call__(							self       ,							A__=None       ,							A__=None       ,							A__=None       ,							**A__      )    ->			Optional[int]:

          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:
             _SCREAMING_SNAKE_CASE      =				self.tokenizer(A__       ,							return_tensors=A__       ,							**A__      )

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

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






       def        UpperCamelCase				(							self       ,							*A__       ,							**A__      )    ->			Dict:
          return self.tokenizer.batch_decode(*A__       ,							**A__      )






       def        UpperCamelCase				(							self       ,							*A__       ,							**A__      )    ->			Optional[Any]:
          return self.tokenizer.decode(*A__       ,							**A__      )






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






       @property
       def        UpperCamelCase				(							self      )    ->			Optional[int]:
          warnings.warn(
              """`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."""       ,							A__       ,							)
          return self.image_processor_class






