





'''simple docstring'''






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


lowerCAmelCase       		=      logging.get_logger(__name__)

lowerCAmelCase       		=      {
    """google/canine-s""": """https://huggingface.co/google/canine-s/resolve/main/config.json""",
    # See all CANINE models at https://huggingface.co/models?filter=canine
}
class 		lowerCamelCase  (      _A       ):
	snake_case_      =   "canine"



	def __init__(   self		,      a_=768		,      a_=12		,      a_=12		,      a_=3_072		,      a_="gelu"		,      a_=0.1		,      a_=0.1		,      a_=16_384		,      a_=16		,      a_=0.02		,      a_=1e-1_2		,      a_=0		,      a_=0xe000		,      a_=0xe001		,      a_=4		,      a_=4		,      a_=8		,      a_=16_384		,      a_=128		,      **a_		,      ):
			super().__init__(pad_token_id=a_		,      bos_token_id=a_		,      eos_token_id=a_		,      **a_	)

			lowerCAmelCase     :    Optional[Any]						=   max_position_embeddings
			lowerCAmelCase     :    Tuple						=   hidden_size
			lowerCAmelCase     :    Optional[int]						=   num_hidden_layers
			lowerCAmelCase     :    Union[str, Any]						=   num_attention_heads
			lowerCAmelCase     :    str						=   intermediate_size
			lowerCAmelCase     :    Dict						=   hidden_act
			lowerCAmelCase     :    List[Any]						=   hidden_dropout_prob
			lowerCAmelCase     :    str						=   attention_probs_dropout_prob
			lowerCAmelCase     :    Tuple						=   initializer_range
			lowerCAmelCase     :    Union[str, Any]						=   type_vocab_size
			lowerCAmelCase     :    Dict						=   layer_norm_eps

			# Character config:
			lowerCAmelCase     :    Optional[int]						=   downsampling_rate
			lowerCAmelCase     :    Optional[Any]						=   upsampling_kernel_size
			lowerCAmelCase     :    List[str]						=   num_hash_functions
			lowerCAmelCase     :    List[str]						=   num_hash_buckets
			lowerCAmelCase     :    Union[str, Any]						=   local_transformer_stride










'''simple docstring'''






import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class 		lowerCamelCase  (      _A       ):
	snake_case_      =   ["image_processor", "tokenizer"]
	snake_case_      =   "ChineseCLIPImageProcessor"
	snake_case_      =   ("BertTokenizer", "BertTokenizerFast")



	def __init__(   self		,      a_=None		,      a_=None		,      **a_	):
			lowerCAmelCase     :    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."		,      a_		,      )
					lowerCAmelCase     :    Optional[Any]						=   kwargs.pop("feature_extractor"	)

			lowerCAmelCase     :    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__(a_		,      a_	)
			lowerCAmelCase     :    Dict						=   self.image_processor



	def __call__(   self		,      a_=None		,      a_=None		,      a_=None		,      **a_	):

			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:
					lowerCAmelCase     :    List[str]						=   self.tokenizer(a_		,      return_tensors=a_		,      **a_	)

			if images is not None:
					lowerCAmelCase     :    List[Any]						=   self.image_processor(a_		,      return_tensors=a_		,      **a_	)

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



	def   _lowerCamelCase    (   self		,      *a_		,      **a_	):
			return self.tokenizer.batch_decode(*a_		,      **a_	)



	def   _lowerCamelCase    (   self		,      *a_		,      **a_	):
			return self.tokenizer.decode(*a_		,      **a_	)



	@property
	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    str						=   self.tokenizer.model_input_names
			lowerCAmelCase     :    List[Any]						=   self.image_processor.model_input_names
			return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names	)	)





	@property
	def   _lowerCamelCase    (   self	):
			warnings.warn(
			    "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."		,      a_		,      )
			return self.image_processor_class



