



'''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


lowercase_									=    logging.get_logger(__name__)

lowercase_									=    {
    "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     (    A		):



 '''simple docstring'''







 __lowerCamelCase       :			str		=			'owlvit_text_model'



 def __init__(self					,  A=49_408					,  A=512					,  A=2_048					,  A=12					,  A=8					,  A=16					,  A="quick_gelu"					,  A=1E-5					,  A=0.0					,  A=0.02					,  A=1.0					,  A=0					,  A=49_406					,  A=49_407					,  **A					,  )       ->	Union[str, Any]:


      """simple docstring"""



      super().__init__(pad_token_id=A					,  bos_token_id=A					,  eos_token_id=A					,  **A			)

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



 @classmethod
 def    a__    (cls					,  A					,  **A			)       ->	"PretrainedConfig":


      """simple docstring"""



      cls._set_token_in_kwargs(A			)

      _a    ,       _a           =    cls.get_config_dict(A					,  **A			)

      # get the text config dict if we are loading from OwlViTConfig
      if config_dict.get('''model_type'''			) == "owlvit":
           _a           =    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(A					,  **A			)






class __A     (    A		):



 '''simple docstring'''







 __lowerCamelCase       :			Dict		=			'owlvit_vision_model'



 def __init__(self					,  A=768					,  A=3_072					,  A=12					,  A=12					,  A=3					,  A=768					,  A=32					,  A="quick_gelu"					,  A=1E-5					,  A=0.0					,  A=0.02					,  A=1.0					,  **A					,  )       ->	Union[str, Any]:


      """simple docstring"""



      super().__init__(**A			)

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



 @classmethod
 def    a__    (cls					,  A					,  **A			)       ->	"PretrainedConfig":


      """simple docstring"""



      cls._set_token_in_kwargs(A			)

      _a    ,       _a           =    cls.get_config_dict(A					,  **A			)

      # get the vision config dict if we are loading from OwlViTConfig
      if config_dict.get('''model_type'''			) == "owlvit":
           _a           =    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(A					,  **A			)






class __A     (    A		):



 '''simple docstring'''







 __lowerCamelCase       :			Optional[int]		=			'owlvit'
 __lowerCamelCase       :			List[str]		=			True



 def __init__(self					,  A=None					,  A=None					,  A=512					,  A=2.6592					,  A=True					,  **A					,  )       ->	Optional[int]:


      """simple docstring"""



      super().__init__(**A			)

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

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

      _a           =    OwlViTTextConfig(**A			)
      _a           =    OwlViTVisionConfig(**A			)

      _a           =    projection_dim
      _a           =    logit_scale_init_value
      _a           =    return_dict
      _a           =    1.0



 @classmethod
 def    a__    (cls					,  A					,  **A			)       ->	"PretrainedConfig":


      """simple docstring"""



      cls._set_token_in_kwargs(A			)

      _a    ,       _a           =    cls.get_config_dict(A					,  **A			)

      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(A					,  **A			)



 @classmethod
 def    a__    (cls					,  A					,  A					,  **A			)       ->	Any:


      """simple docstring"""



      _a           =    {}
      _a           =    text_config
      _a           =    vision_config

      return cls.from_dict(A					,  **A			)



 def    a__    (self			)       ->	Tuple:


      """simple docstring"""



      _a           =    copy.deepcopy(self.__dict__			)
      _a           =    self.text_config.to_dict()
      _a           =    self.vision_config.to_dict()
      _a           =    self.__class__.model_type
      return output






class __A     (    A		):



 '''simple docstring'''







 @property
 def    a__    (self			)       ->	Mapping[str, Mapping[int, str]]:


      """simple docstring"""



      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    a__    (self			)       ->	Mapping[str, Mapping[int, str]]:


      """simple docstring"""



      return OrderedDict(
          [
              ('''logits_per_image''', {0: '''batch'''}),
              ('''logits_per_text''', {0: '''batch'''}),
              ('''text_embeds''', {0: '''batch'''}),
              ('''image_embeds''', {0: '''batch'''}),
          ]			)



 @property
 def    a__    (self			)       ->	float:


      """simple docstring"""



      return 1E-4



 def    a__    (self					,  A					,  A = -1					,  A = -1					,  A = None					,  )       ->	Mapping[str, Any]:


      """simple docstring"""



      _a           =    super().generate_dummy_inputs(
          processor.tokenizer					,  batch_size=A					,  seq_length=A					,  framework=A			)
      _a           =    super().generate_dummy_inputs(
          processor.image_processor					,  batch_size=A					,  framework=A			)
      return {**text_input_dict, **image_input_dict}



 @property
 def    a__    (self			)       ->	int:


      """simple docstring"""



      return 14








'''simple docstring'''





from __future__ import annotations




def lowerCAmelCase    (__A):



     """simple docstring"""



     _a           =    2
     _a           =    []
     while i * i <= n:
          if n % i:
               i += 1
          else:
               n //= i
               factors.append(__A)
     if n > 1:
          factors.append(__A)
     return factors


if __name__ == "__main__":
  import doctest

  doctest.testmod()



