import warnings

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






class 		_lowerCamelCase		( UpperCamelCase_     ):
    __a						=   ["image_processor", "tokenizer"]
    __a						=   "CLIPImageProcessor"
    __a						=   ("CLIPTokenizer", "CLIPTokenizerFast")
    def __init__(	self			,			lowerCAmelCase=None			,			lowerCAmelCase=None			,			**lowerCAmelCase )							->       Any:
     SCREAMING_SNAKE_CASE__: Optional[int]=   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			,			)
      SCREAMING_SNAKE_CASE__: Tuple=   kwargs.pop('''feature_extractor''' )

     SCREAMING_SNAKE_CASE__: 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__(lowerCAmelCase			,			lowerCAmelCase )
    def __call__(	self			,			lowerCAmelCase=None			,			lowerCAmelCase=None			,			lowerCAmelCase=None			,			**lowerCAmelCase )							->       Any:

     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__: Optional[Any]=   self.tokenizer(lowerCAmelCase			,			return_tensors=lowerCAmelCase			,			**lowerCAmelCase )

     if images is not None:
      SCREAMING_SNAKE_CASE__: Tuple=   self.image_processor(lowerCAmelCase			,			return_tensors=lowerCAmelCase			,			**lowerCAmelCase )

     if text is not None and images is not None:
      SCREAMING_SNAKE_CASE__: str=   image_features.pixel_values
      return encoding
     elif text is not None:
      return encoding
     else:
      return BatchEncoding(data=dict(**lowerCAmelCase )			,			tensor_type=lowerCAmelCase )
    def     UpperCamelCase_					(	self			,			*lowerCAmelCase			,			**lowerCAmelCase )							->       Dict:
     return self.tokenizer.batch_decode(*lowerCAmelCase			,			**lowerCAmelCase )
    def     UpperCamelCase_					(	self			,			*lowerCAmelCase			,			**lowerCAmelCase )							->       List[str]:
     return self.tokenizer.decode(*lowerCAmelCase			,			**lowerCAmelCase )
    @property
    def     UpperCamelCase_					(	self )							->       Dict:
     SCREAMING_SNAKE_CASE__: Union[str, Any]=   self.tokenizer.model_input_names
     SCREAMING_SNAKE_CASE__: Any=   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.'''			,			lowerCAmelCase			,			)
     return self.image_processor_class



    @property
    def     UpperCamelCase_					(	self )							->       Tuple:
     warnings.warn(
         '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'''			,			lowerCAmelCase			,			)
     return self.image_processor





'''simple docstring'''



from .dependency_versions_table import deps
from .utils.versions import require_version, require_version_core


# define which module versions we always want to check at run time
# (usually the ones defined in `install_requires` in setup.py)
#
# order specific notes:
# - tqdm must be checked before tokenizers

A__						:   Dict				=    [
    """python""",
    """tqdm""",
    """regex""",
    """requests""",
    """packaging""",
    """filelock""",
    """numpy""",
    """tokenizers""",
    """huggingface-hub""",
    """safetensors""",
    """accelerate""",
    """pyyaml""",
]

for pkg in pkgs_to_check_at_runtime:
      if pkg in deps:
            if pkg == "tokenizers":
                  # must be loaded here, or else tqdm check may fail
                  from .utils import is_tokenizers_available

                  if not is_tokenizers_available():
                        continue  # not required, check version only if installed
            elif pkg == "accelerate":
                  # must be loaded here, or else tqdm check may fail
                  from .utils import is_accelerate_available

                  # Maybe switch to is_torch_available in the future here so that Accelerate is hard dep of
                  # Transformers with PyTorch
                  if not is_accelerate_available():
                        continue  # not required, check version only if installed

            require_version_core(deps[pkg])
      else:
            raise ValueError(f'''can\'t find {pkg} in {deps.keys()}, check dependency_versions_table.py''')



def      UpperCAmelCase__   (      UpperCAmelCase_       :							List[Any] ,       UpperCAmelCase_       :							List[Any]=None				)	->						List[Any]:
     require_version(deps[pkg] ,       UpperCAmelCase_				)






