





import warnings

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




class   UpperCamelCase_       (     UpperCamelCase__    ):
       lowerCamelCase_           =					["image_processor", "tokenizer"]
       lowerCamelCase_           =					"ChineseCLIPImageProcessor"
       lowerCamelCase_           =					("BertTokenizer", "BertTokenizerFast")


       def __init__(							self    :List[str]							,				__A    :int=None							,				__A    :Optional[Any]=None							,				**__A    :Optional[Any]		)   ->   str:



         """simple docstring"""



         SCREAMING_SNAKE_CASE__			=      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							,				)
           SCREAMING_SNAKE_CASE__			=      kwargs.pop("""feature_extractor"""		)

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


       def __call__(							self    :List[str]							,				__A    :Tuple=None							,				__A    :int=None							,				__A    :Optional[int]=None							,				**__A    :List[Any]		)   ->   Tuple:



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

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

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


       def      _snake_case  (							self    :List[Any]							,				*__A    :Union[str, Any]							,				**__A    :Union[str, Any]		)   ->   Union[str, Any]:



         """simple docstring"""



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


       def      _snake_case  (							self    :Any							,				*__A    :Optional[int]							,				**__A    :str		)   ->   List[Any]:



         """simple docstring"""



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


       @property
       def      _snake_case  (							self    :Any		)   ->   Dict:



         """simple docstring"""



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


       @property
       def      _snake_case  (							self    :Dict		)   ->   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






from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowerCamelCase   				=			logging.get_logger(__name__)




class   UpperCamelCase_       (     UpperCamelCase__    ):
							lowerCamelCase_           =					"timm_backbone"


							def __init__(							self    :Union[str, Any]							,				__A    :str=None							,				__A    :Union[str, Any]=3							,				__A    :str=True							,				__A    :Any=True							,				__A    :Optional[Any]=None							,				**__A    :List[str]							,				)   ->   Tuple:



									"""simple docstring"""



									super().__init__(**__A		)
									SCREAMING_SNAKE_CASE__			=      backbone
									SCREAMING_SNAKE_CASE__			=      num_channels
									SCREAMING_SNAKE_CASE__			=      features_only
									SCREAMING_SNAKE_CASE__			=      use_pretrained_backbone
									SCREAMING_SNAKE_CASE__			=      True
									SCREAMING_SNAKE_CASE__			=      out_indices if out_indices is not None else (-1,)