





import warnings

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





class      lowercase__    (							__A  ):
  __UpperCamelCase	     =  ["""image_processor""", """tokenizer"""]
  __UpperCamelCase	     =  """CLIPImageProcessor"""
  __UpperCamelCase	     =  ("""CLIPTokenizer""", """CLIPTokenizerFast""")







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

       lowerCAmelCase_					:       int    =		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__(_lowercase    ,						_lowercase						)







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

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

       if images is not None:
            lowerCAmelCase_					:       int    =		self.image_processor(_lowercase    ,						return_tensors=_lowercase    ,						**_lowercase						)

       if text is not None and images is not None:
            lowerCAmelCase_					:       Optional[Any]    =		image_features.pixel_values
            return encoding
       elif text is not None:
            return encoding
       else:
            return BatchEncoding(data=dict(**_lowercase						)    ,						tensor_type=_lowercase						)







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







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







  @property
  def 	UpperCAmelCase__		(	self						):
       lowerCAmelCase_					:       Dict    =		self.tokenizer.model_input_names
       lowerCAmelCase_					:       Optional[int]    =		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."""    ,						_lowercase    ,						)
       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."""    ,						_lowercase    ,						)
       return self.image_processor







from collections import namedtuple

UpperCAmelCase_					:   Union[str, Any] 							=						namedtuple("""from_to""", """from_ to""")

UpperCAmelCase_					:   int 							=						{
    """cubicmeter""": from_to(1, 1),
    """litre""": from_to(0.0_01, 10_00),
    """kilolitre""": from_to(1, 1),
    """gallon""": from_to(0.0_04_54, 2_64.1_72),
    """cubicyard""": from_to(0.7_64_55, 1.3_07_95),
    """cubicfoot""": from_to(0.0_28, 35.31_47),
    """cup""": from_to(0.0_00_23_65_88, 42_26.75),
}






def 							_lowerCAmelCase (  _a   :					float					,   _a   :					str					,   _a   :					str			)	->			float:
     if from_type not in METRIC_CONVERSION:
          raise ValueError(
              F'Invalid \'from_type\' value: {from_type!r}  Supported values are:\n'
              + """, """.join(_a			)			)
     if to_type not in METRIC_CONVERSION:
          raise ValueError(
              F'Invalid \'to_type\' value: {to_type!r}.  Supported values are:\n'
              + """, """.join(_a			)			)
     return value * METRIC_CONVERSION[from_type].from_ * METRIC_CONVERSION[to_type].to


if __name__ == "__main__":
      import doctest

      doctest.testmod()
