

import warnings

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







class 						__magic_name__			(							lowerCamelCase__							):

   '''simple docstring'''




   lowerCamelCase__ :	List[Any]    =   ['image_processor', 'tokenizer']
   lowerCamelCase__ :	Dict    =   'ChineseCLIPImageProcessor'
   lowerCamelCase__ :	str    =   ('BertTokenizer', 'BertTokenizerFast')



   def __init__(				self,    lowercase_=None,    lowercase_=None,    **lowercase_       )							->    Optional[Any]:






     """simple docstring"""






     a__  =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_,    )
       a__  =kwargs.pop('''feature_extractor'''       )

     a__  =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_       )
     a__  =self.image_processor



   def __call__(				self,    lowercase_=None,    lowercase_=None,    lowercase_=None,    **lowercase_       )							->    Union[str, Any]:






     """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:
       a__  =self.tokenizer(lowercase_,    return_tensors=lowercase_,    **lowercase_       )

     if images is not None:
       a__  =self.image_processor(lowercase_,    return_tensors=lowercase_,    **lowercase_       )

     if text is not None and images is not None:
       a__  =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_       )							->    Union[str, Any]:






     """simple docstring"""






     return self.tokenizer.batch_decode(*lowercase_,    **lowercase_       )



   def  _UpperCAmelCase (				self,    *lowercase_,    **lowercase_       )							->    Tuple:






     """simple docstring"""






     return self.tokenizer.decode(*lowercase_,    **lowercase_       )



   @property
   def  _UpperCAmelCase (				self       )							->    Any:






     """simple docstring"""






     a__  =self.tokenizer.model_input_names
     a__  =self.image_processor.model_input_names
     return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names       )       )



   @property
   def  _UpperCAmelCase (				self       )							->    str:






     """simple docstring"""






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



def 			UpperCAmelCase__				(			_A      : dict							):





  '''simple docstring'''







  a__  =set()
  # To detect a back edge, keep track of vertices currently in the recursion stack
  a__  =set()
  return any(
      node not in visited and depth_first_search(_A	,      _A	,      _A	,      _A							)
      for node in graph							)




def 			UpperCAmelCase__				(			_A      : dict	,      _A      : int	,      _A      : set	,      _A      : set							):





  '''simple docstring'''







  visited.add(_A							)
  rec_stk.add(_A							)

  for node in graph[vertex]:
    if node not in visited:
      if depth_first_search(_A	,      _A	,      _A	,      _A							):
        return True
    elif node in rec_stk:
      return True

    # The node needs to be removed from recursion stack before function ends
  rec_stk.remove(_A							)
  return False


if __name__ == "__main__":
       from doctest import testmod

       testmod()
