






from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


SCREAMING_SNAKE_CASE__		:							List[Any] 				=				logging.get_logger(__name__)

SCREAMING_SNAKE_CASE__		:							Optional[Any] 				=				{
    """google/vit-base-patch16-224""": """https://huggingface.co/vit-base-patch16-224/resolve/main/config.json""",
    # See all ViT models at https://huggingface.co/models?filter=vit
}







class 				UpperCAmelCase_  (		__lowerCamelCase		):
     __lowerCamelCase      				=  'vit'




     def __init__(				self	,						_lowerCAmelCase=768	,						_lowerCAmelCase=12	,						_lowerCAmelCase=12	,						_lowerCAmelCase=3072	,						_lowerCAmelCase="gelu"	,						_lowerCAmelCase=0.0	,						_lowerCAmelCase=0.0	,						_lowerCAmelCase=0.0_2	,						_lowerCAmelCase=1e-12	,						_lowerCAmelCase=224	,						_lowerCAmelCase=16	,						_lowerCAmelCase=3	,						_lowerCAmelCase=True	,						_lowerCAmelCase=16	,						**_lowerCAmelCase	,						):
          super().__init__(**_lowerCAmelCase		)

          UpperCAmelCase__      :  Dict				      =			hidden_size
          UpperCAmelCase__      :  List[Any]				      =			num_hidden_layers
          UpperCAmelCase__      :  Any				      =			num_attention_heads
          UpperCAmelCase__      :  str				      =			intermediate_size
          UpperCAmelCase__      :  Tuple				      =			hidden_act
          UpperCAmelCase__      :  Tuple				      =			hidden_dropout_prob
          UpperCAmelCase__      :  List[str]				      =			attention_probs_dropout_prob
          UpperCAmelCase__      :  str				      =			initializer_range
          UpperCAmelCase__      :  Any				      =			layer_norm_eps
          UpperCAmelCase__      :  int				      =			image_size
          UpperCAmelCase__      :  Any				      =			patch_size
          UpperCAmelCase__      :  str				      =			num_channels
          UpperCAmelCase__      :  List[str]				      =			qkv_bias
          UpperCAmelCase__      :  Optional[Any]				      =			encoder_stride







class 				UpperCAmelCase_  (		__lowerCamelCase		):
     __lowerCamelCase      				=  version.parse('1.11'		)




     @property
     def   __UpperCAmelCase  (				self		):
          return OrderedDict(
              [
                  ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
              ]		)




     @property
     def   __UpperCAmelCase  (				self		):
          return 1e-4











import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class    __UpperCamelCase			(       _lowercase				):

 """simple docstring"""



 _lowercase   :    Optional[Any]      						=					['''image_processor''', '''tokenizer''']
 _lowercase   :    Optional[int]      						=					'''ChineseCLIPImageProcessor'''
 _lowercase   :    List[Any]      						=					('''BertTokenizer''', '''BertTokenizerFast''')

 def __init__(	self		,				SCREAMING_SNAKE_CASE=None		,				SCREAMING_SNAKE_CASE=None		,				**SCREAMING_SNAKE_CASE      ) ->			Union[str, Any]:
  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.'''		,				SCREAMING_SNAKE_CASE		,				)
   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__(SCREAMING_SNAKE_CASE		,				SCREAMING_SNAKE_CASE      )
  a__												= self.image_processor

 def __call__(	self		,				SCREAMING_SNAKE_CASE=None		,				SCREAMING_SNAKE_CASE=None		,				SCREAMING_SNAKE_CASE=None		,				**SCREAMING_SNAKE_CASE      ) ->			List[str]:

  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(SCREAMING_SNAKE_CASE		,				return_tensors=SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      )

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

  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(**SCREAMING_SNAKE_CASE      )		,				tensor_type=SCREAMING_SNAKE_CASE      )

 def 						_UpperCAmelCase       (	self		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      ) ->			List[str]:
  return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      )

 def 						_UpperCAmelCase       (	self		,				*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      ) ->			int:
  return self.tokenizer.decode(*SCREAMING_SNAKE_CASE		,				**SCREAMING_SNAKE_CASE      )

 @property
 def 						_UpperCAmelCase       (	self      ) ->			List[str]:
  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      ) ->			Optional[int]:
  warnings.warn(
      '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''		,				SCREAMING_SNAKE_CASE		,				)
  return self.image_processor_class





