




'''simple docstring'''


import copy
import os
from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union


if TYPE_CHECKING:
  from ...processing_utils import ProcessorMixin
  from ...utils import TensorType

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


_lowerCAmelCase  		=      logging.get_logger(__name__)

_lowerCAmelCase  		=      {
    "google/owlvit-base-patch32": "https://huggingface.co/google/owlvit-base-patch32/resolve/main/config.json",
    "google/owlvit-base-patch16": "https://huggingface.co/google/owlvit-base-patch16/resolve/main/config.json",
    "google/owlvit-large-patch14": "https://huggingface.co/google/owlvit-large-patch14/resolve/main/config.json",
}
class   __A (							SCREAMING_SNAKE_CASE__  ):



   """simple docstring"""







   A_												=				'owlvit_text_model'

   def __init__(      self				, _lowerCamelCase=4_9_4_0_8				, _lowerCamelCase=5_1_2				, _lowerCamelCase=2_0_4_8				, _lowerCamelCase=1_2				, _lowerCamelCase=8				, _lowerCamelCase=1_6				, _lowerCamelCase="quick_gelu"				, _lowerCamelCase=1e-5				, _lowerCamelCase=0.0				, _lowerCamelCase=0.0_2				, _lowerCamelCase=1.0				, _lowerCamelCase=0				, _lowerCamelCase=4_9_4_0_6				, _lowerCamelCase=4_9_4_0_7				, **_lowerCamelCase				, )->       str:
      super().__init__(pad_token_id=__lowerCamelCase				, bos_token_id=__lowerCamelCase				, eos_token_id=__lowerCamelCase				, **__lowerCamelCase						)

      lowercase__       							=							vocab_size
      lowercase__       							=							hidden_size
      lowercase__       							=							intermediate_size
      lowercase__       							=							num_hidden_layers
      lowercase__       							=							num_attention_heads
      lowercase__       							=							max_position_embeddings
      lowercase__       							=							hidden_act
      lowercase__       							=							layer_norm_eps
      lowercase__       							=							attention_dropout
      lowercase__       							=							initializer_range
      lowercase__       							=							initializer_factor

   @classmethod
   def snake_case_(      cls				, _lowerCamelCase				, **_lowerCamelCase						)->       Tuple:
      cls._set_token_in_kwargs(__lowerCamelCase						)

      lowercase__       							=							cls.get_config_dict(__lowerCamelCase				, **__lowerCamelCase						)

      # get the text config dict if we are loading from OwlViTConfig
      if config_dict.get('''model_type'''						) == "owlvit":
         lowercase__       							=							config_dict['''text_config''']

      if "model_type" in config_dict and hasattr(cls				, '''model_type'''						) and config_dict["model_type"] != cls.model_type:
         logger.warning(
             f'''You are using a model of type {config_dict['model_type']} to instantiate a model of type '''
             f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''						)

      return cls.from_dict(__lowerCamelCase				, **__lowerCamelCase						)



class   __A (							SCREAMING_SNAKE_CASE__  ):



   """simple docstring"""







   A_												=				'owlvit_vision_model'

   def __init__(      self				, _lowerCamelCase=7_6_8				, _lowerCamelCase=3_0_7_2				, _lowerCamelCase=1_2				, _lowerCamelCase=1_2				, _lowerCamelCase=3				, _lowerCamelCase=7_6_8				, _lowerCamelCase=3_2				, _lowerCamelCase="quick_gelu"				, _lowerCamelCase=1e-5				, _lowerCamelCase=0.0				, _lowerCamelCase=0.0_2				, _lowerCamelCase=1.0				, **_lowerCamelCase				, )->       str:
      super().__init__(**__lowerCamelCase						)

      lowercase__       							=							hidden_size
      lowercase__       							=							intermediate_size
      lowercase__       							=							num_hidden_layers
      lowercase__       							=							num_attention_heads
      lowercase__       							=							num_channels
      lowercase__       							=							image_size
      lowercase__       							=							patch_size
      lowercase__       							=							hidden_act
      lowercase__       							=							layer_norm_eps
      lowercase__       							=							attention_dropout
      lowercase__       							=							initializer_range
      lowercase__       							=							initializer_factor

   @classmethod
   def snake_case_(      cls				, _lowerCamelCase				, **_lowerCamelCase						)->       List[Any]:
      cls._set_token_in_kwargs(__lowerCamelCase						)

      lowercase__       							=							cls.get_config_dict(__lowerCamelCase				, **__lowerCamelCase						)

      # get the vision config dict if we are loading from OwlViTConfig
      if config_dict.get('''model_type'''						) == "owlvit":
         lowercase__       							=							config_dict['''vision_config''']

      if "model_type" in config_dict and hasattr(cls				, '''model_type'''						) and config_dict["model_type"] != cls.model_type:
         logger.warning(
             f'''You are using a model of type {config_dict['model_type']} to instantiate a model of type '''
             f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''						)

      return cls.from_dict(__lowerCamelCase				, **__lowerCamelCase						)



class   __A (							SCREAMING_SNAKE_CASE__  ):



   """simple docstring"""







   A_												=				'owlvit'
   A_												=				True

   def __init__(      self				, _lowerCamelCase=None				, _lowerCamelCase=None				, _lowerCamelCase=5_1_2				, _lowerCamelCase=2.6_5_9_2				, _lowerCamelCase=True				, **_lowerCamelCase				, )->       int:
      super().__init__(**__lowerCamelCase						)

      if text_config is None:
         lowercase__       							=							{}
         logger.info('''text_config is None. Initializing the OwlViTTextConfig with default values.'''						)

      if vision_config is None:
         lowercase__       							=							{}
         logger.info('''vision_config is None. initializing the OwlViTVisionConfig with default values.'''						)

      lowercase__       							=							OwlViTTextConfig(**__lowerCamelCase						)
      lowercase__       							=							OwlViTVisionConfig(**__lowerCamelCase						)

      lowercase__       							=							projection_dim
      lowercase__       							=							logit_scale_init_value
      lowercase__       							=							return_dict
      lowercase__       							=							1.0

   @classmethod
   def snake_case_(      cls				, _lowerCamelCase				, **_lowerCamelCase						)->       Dict:
      cls._set_token_in_kwargs(__lowerCamelCase						)

      lowercase__       							=							cls.get_config_dict(__lowerCamelCase				, **__lowerCamelCase						)

      if "model_type" in config_dict and hasattr(cls				, '''model_type'''						) and config_dict["model_type"] != cls.model_type:
         logger.warning(
             f'''You are using a model of type {config_dict['model_type']} to instantiate a model of type '''
             f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''						)

      return cls.from_dict(__lowerCamelCase				, **__lowerCamelCase						)

   @classmethod
   def snake_case_(      cls				, _lowerCamelCase				, _lowerCamelCase				, **_lowerCamelCase						)->       Optional[Any]:
      lowercase__       							=							{}
      lowercase__       							=							text_config
      lowercase__       							=							vision_config

      return cls.from_dict(__lowerCamelCase				, **__lowerCamelCase						)

   def snake_case_(      self						)->       Optional[Any]:
      lowercase__       							=							copy.deepcopy(self.__dict__						)
      lowercase__       							=							self.text_config.to_dict()
      lowercase__       							=							self.vision_config.to_dict()
      lowercase__       							=							self.__class__.model_type
      return output



class   __A (							SCREAMING_SNAKE_CASE__  ):



   """simple docstring"""







   @property
   def snake_case_(      self						)->       Tuple:
      return OrderedDict(
          [
              ('''input_ids''', {0: '''batch''', 1: '''sequence'''}),
              ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
              ('''attention_mask''', {0: '''batch''', 1: '''sequence'''}),
          ]						)

   @property
   def snake_case_(      self						)->       Any:
      return OrderedDict(
          [
              ('''logits_per_image''', {0: '''batch'''}),
              ('''logits_per_text''', {0: '''batch'''}),
              ('''text_embeds''', {0: '''batch'''}),
              ('''image_embeds''', {0: '''batch'''}),
          ]						)

   @property
   def snake_case_(      self						)->       List[str]:
      return 1e-4

   def snake_case_(      self				, _lowerCamelCase				, _lowerCamelCase = -1				, _lowerCamelCase = -1				, _lowerCamelCase = None				, )->       str:
      lowercase__       							=							super().generate_dummy_inputs(
          processor.tokenizer				, batch_size=__lowerCamelCase				, seq_length=__lowerCamelCase				, framework=__lowerCamelCase						)
      lowercase__       							=							super().generate_dummy_inputs(
          processor.image_processor				, batch_size=__lowerCamelCase				, framework=__lowerCamelCase						)
      return {**text_input_dict, **image_input_dict}

   @property
   def snake_case_(      self						)->       Tuple:
      return 1_4











"""simple docstring"""



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


a_					=     logging.get_logger(__name__)

a_					=     {
    """sail/poolformer_s12""": """https://huggingface.co/sail/poolformer_s12/resolve/main/config.json""",
    # See all PoolFormer models at https://huggingface.co/models?filter=poolformer
}






class 						__snake_case   (						SCREAMING_SNAKE_CASE__	):





 """simple docstring"""


 _lowerCamelCase								=	"""poolformer"""

 def __init__(       self   ,		__lowerCamelCase=3   ,		__lowerCamelCase=16   ,		__lowerCamelCase=16   ,		__lowerCamelCase=3   ,		__lowerCamelCase=4.0   ,		__lowerCamelCase=[2, 2, 6, 2]   ,		__lowerCamelCase=[64, 128, 320, 512]   ,		__lowerCamelCase=[7, 3, 3, 3]   ,		__lowerCamelCase=[4, 2, 2, 2]   ,		__lowerCamelCase=[2, 1, 1, 1]   ,		__lowerCamelCase=4   ,		__lowerCamelCase=0.0   ,		__lowerCamelCase="gelu"   ,		__lowerCamelCase=True   ,		__lowerCamelCase=1e-5   ,		__lowerCamelCase=0.0_2   ,		**__lowerCamelCase   ,		):



     '''simple docstring'''




     __A       :		str							=	num_channels
     __A       :		List[str]							=	patch_size
     __A       :		str							=	stride
     __A       :		Any							=	padding
     __A       :		Any							=	pool_size
     __A       :		Dict							=	hidden_sizes
     __A       :		Optional[Any]							=	mlp_ratio
     __A       :		Any							=	depths
     __A       :		List[str]							=	patch_sizes
     __A       :		Union[str, Any]							=	strides
     __A       :		List[str]							=	num_encoder_blocks
     __A       :		Optional[int]							=	drop_path_rate
     __A       :		Union[str, Any]							=	hidden_act
     __A       :		Optional[Any]							=	use_layer_scale
     __A       :		List[Any]							=	layer_scale_init_value
     __A       :		List[Any]							=	initializer_range
     super().__init__(**__lowerCamelCase    )






class 						__snake_case   (						SCREAMING_SNAKE_CASE__	):





 """simple docstring"""


 _lowerCamelCase								=	version.parse("""1.11"""	)

 @property
 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     return OrderedDict(
         [
             ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
         ]    )







 @property
 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     return 2e-3




