import warnings

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




class 			__magic_name__	(		__a     ):





   """simple docstring"""




   lowerCAmelCase   :     str	      = ['''image_processor''', '''tokenizer''']
   lowerCAmelCase   :     Any	      = '''ChineseCLIPImageProcessor'''
   lowerCAmelCase   :     Union[str, Any]	      = ('''BertTokenizer''', '''BertTokenizerFast''')



   def __init__(						self       :	Tuple		,	_lowercase       :	Union[str, Any]=None		,	_lowercase       :	Dict=None		,	**_lowercase       :	Tuple				):



    """simple docstring"""



    _UpperCamelCase:  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		,	)
     _UpperCamelCase:  Optional[int]    						=			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__(_lowercase		,	_lowercase				)
    _UpperCamelCase:  Any    						=			self.image_processor



   def __call__(						self       :	Union[str, Any]		,	_lowercase       :	Tuple=None		,	_lowercase       :	List[str]=None		,	_lowercase       :	Tuple=None		,	**_lowercase       :	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:
     _UpperCamelCase:  int    						=			self.tokenizer(_lowercase		,	return_tensors=_lowercase		,	**_lowercase				)

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

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



   def 	lowerCAmelCase    (						self       :	Optional[int]		,	*_lowercase       :	Optional[int]		,	**_lowercase       :	Tuple				):



    """simple docstring"""



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



   def 	lowerCAmelCase    (						self       :	Dict		,	*_lowercase       :	List[str]		,	**_lowercase       :	int				):



    """simple docstring"""



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



   @property
   def 	lowerCAmelCase    (						self       :	Union[str, Any]				):



    """simple docstring"""



    _UpperCamelCase:  Any    						=			self.tokenizer.model_input_names
    _UpperCamelCase:  Tuple    						=			self.image_processor.model_input_names
    return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names				)				)



   @property
   def 	lowerCAmelCase    (						self       :	Tuple				):



    """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
import torch




def    lowerCAmelCase_  (		)     ->					int:







 '''simple docstring'''
 if torch.cuda.is_available():
  _UpperCamelCase:  Any    						=			torch.cuda.device_count()
 else:
  _UpperCamelCase:  Union[str, Any]    						=			0
 print(F"""Successfully ran on {num_gpus} GPUs"""		)


if __name__ == "__main__":
  main()