

"""simple docstring"""




import warnings

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







class      __lowercase			(    __lowerCamelCase					):
  snake_case_				       =       ["""image_processor""", """tokenizer"""]
  snake_case_				       =       """ChineseCLIPImageProcessor"""
  snake_case_				       =       ("""BertTokenizer""", """BertTokenizerFast""")

  def __init__(  self		:			Optional[int]					,A		:			int=None					,A		:			str=None					,**A		:			Union[str, Any]    ):






   '''simple docstring'''
   UpperCAmelCase__					:  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."""					,A					,)
    UpperCAmelCase__					:  Any					   =					kwargs.pop("""feature_extractor"""    )

   UpperCAmelCase__					:  List[Any]					   =					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    )
   UpperCAmelCase__					:  Union[str, Any]					   =					self.image_processor

  def __call__(  self		:			Optional[Any]					,A		:			Union[str, Any]=None					,A		:			Tuple=None					,A		:			Any=None					,**A		:			int    ):






   '''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:
    UpperCAmelCase__					:  Any					   =					self.tokenizer(A					,return_tensors=A					,**A    )

   if images is not None:
    UpperCAmelCase__					:  str					   =					self.image_processor(A					,return_tensors=A					,**A    )

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

  def    __lowercase       (  self		:			Union[str, Any]					,*A		:			Tuple					,**A		:			Union[str, Any]    ):






   '''simple docstring'''
   return self.tokenizer.batch_decode(*A					,**A    )

  def    __lowercase       (  self		:			List[str]					,*A		:			Tuple					,**A		:			Optional[int]    ):






   '''simple docstring'''
   return self.tokenizer.decode(*A					,**A    )

  @property
  def    __lowercase       (  self		:			List[str]    ):






   '''simple docstring'''
   UpperCAmelCase__					:  List[Any]					   =					self.tokenizer.model_input_names
   UpperCAmelCase__					:  str					   =					self.image_processor.model_input_names
   return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names    )    )




  @property
  def    __lowercase       (  self		:			List[Any]    ):






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








"""simple docstring"""




# tests directory-specific settings - this file is run automatically
# by pytest before any tests are run

import sys
import warnings
from os.path import abspath, dirname, join


# allow having multiple repository checkouts and not needing to remember to rerun
# 'pip install -e .[dev]' when switching between checkouts and running tests.
__UpperCAmelCase =				abspath(join(dirname(dirname(__file__)), 'src'))
sys.path.insert(1, git_repo_path)

# silence FutureWarning warnings in tests since often we can't act on them until
# they become normal warnings - i.e. the tests still need to test the current functionality
warnings.simplefilter(action='ignore', category=FutureWarning)
def   lowerCAmelCase						(					__UpperCamelCase      ):
 '''simple docstring'''





 from diffusers.utils.testing_utils import pytest_addoption_shared

 pytest_addoption_shared(__UpperCamelCase      )




def   lowerCAmelCase						(					__UpperCamelCase      ):
 '''simple docstring'''





 from diffusers.utils.testing_utils import pytest_terminal_summary_main

 UpperCAmelCase__					:  Optional[Any]					   =					terminalreporter.config.getoption("""--make-reports"""      )
 if make_reports:
  pytest_terminal_summary_main(__UpperCamelCase							,    id=__UpperCamelCase      )





