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


A__   :		Union[str, Any] 		=logging.get_logger(__name__)

A__   :		Tuple 		={
    '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			):
 lowerCamelCase				       ='''owlvit_text_model'''
 def __init__(   self			:    Dict				,   lowerCamelCase			:    List[Any]=4_94_08				,   lowerCamelCase			:    Optional[int]=5_12				,   lowerCamelCase			:    int=20_48				,   lowerCamelCase			:    int=12				,   lowerCamelCase			:    Union[str, Any]=8				,   lowerCamelCase			:    Optional[Any]=16				,   lowerCamelCase			:    List[str]="quick_gelu"				,   lowerCamelCase			:    List[str]=1e-5				,   lowerCamelCase			:    Optional[Any]=0.0				,   lowerCamelCase			:    List[str]=0.02				,   lowerCamelCase			:    Any=1.0				,   lowerCamelCase			:    str=0				,   lowerCamelCase			:    Union[str, Any]=4_94_06				,   lowerCamelCase			:    List[str]=4_94_07				,   **lowerCamelCase			:    str				,   ):



   """simple docstring"""





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

   __A		:     Any												=		vocab_size
   __A		:     Optional[Any]												=		hidden_size
   __A		:     Tuple												=		intermediate_size
   __A		:     Tuple												=		num_hidden_layers
   __A		:     Dict												=		num_attention_heads
   __A		:     int												=		max_position_embeddings
   __A		:     Optional[int]												=		hidden_act
   __A		:     str												=		layer_norm_eps
   __A		:     Any												=		attention_dropout
   __A		:     Union[str, Any]												=		initializer_range
   __A		:     Union[str, Any]												=		initializer_factor






 @classmethod
 def 		lowercase_(   cls			:    Union[str, Any]				,   lowerCamelCase			:    Union[str, os.PathLike]				,   **lowerCamelCase			:    Dict       ):



   """simple docstring"""





   cls._set_token_in_kwargs(lowerCamelCase       )

   __A							,					__A		:     List[str]												=		cls.get_config_dict(lowerCamelCase				,   **lowerCamelCase       )

   # get the text config dict if we are loading from OwlViTConfig
   if config_dict.get("""model_type"""       ) == "owlvit":
     __A		:     Optional[int]												=		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			):
 lowerCamelCase				       ='''owlvit_vision_model'''
 def __init__(   self			:    List[Any]				,   lowerCamelCase			:    Optional[Any]=7_68				,   lowerCamelCase			:    Any=30_72				,   lowerCamelCase			:    str=12				,   lowerCamelCase			:    Any=12				,   lowerCamelCase			:    List[Any]=3				,   lowerCamelCase			:    Union[str, Any]=7_68				,   lowerCamelCase			:    List[str]=32				,   lowerCamelCase			:    Optional[Any]="quick_gelu"				,   lowerCamelCase			:    Any=1e-5				,   lowerCamelCase			:    List[str]=0.0				,   lowerCamelCase			:    List[Any]=0.02				,   lowerCamelCase			:    int=1.0				,   **lowerCamelCase			:    Optional[Any]				,   ):



   """simple docstring"""





   super().__init__(**lowerCamelCase       )

   __A		:     Optional[Any]												=		hidden_size
   __A		:     List[Any]												=		intermediate_size
   __A		:     List[str]												=		num_hidden_layers
   __A		:     Dict												=		num_attention_heads
   __A		:     Union[str, Any]												=		num_channels
   __A		:     List[Any]												=		image_size
   __A		:     Union[str, Any]												=		patch_size
   __A		:     Optional[int]												=		hidden_act
   __A		:     List[Any]												=		layer_norm_eps
   __A		:     str												=		attention_dropout
   __A		:     Optional[Any]												=		initializer_range
   __A		:     Any												=		initializer_factor






 @classmethod
 def 		lowercase_(   cls			:    str				,   lowerCamelCase			:    Union[str, os.PathLike]				,   **lowerCamelCase			:    Optional[int]       ):



   """simple docstring"""





   cls._set_token_in_kwargs(lowerCamelCase       )

   __A							,					__A		:     Dict												=		cls.get_config_dict(lowerCamelCase				,   **lowerCamelCase       )

   # get the vision config dict if we are loading from OwlViTConfig
   if config_dict.get("""model_type"""       ) == "owlvit":
     __A		:     Union[str, Any]												=		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			):
 lowerCamelCase				       ='''owlvit'''
 lowerCamelCase				       =True
 def __init__(   self			:    int				,   lowerCamelCase			:    int=None				,   lowerCamelCase			:    Dict=None				,   lowerCamelCase			:    Optional[Any]=5_12				,   lowerCamelCase			:    Optional[int]=2.6_592				,   lowerCamelCase			:    Union[str, Any]=True				,   **lowerCamelCase			:    Union[str, Any]				,   ):



   """simple docstring"""





   super().__init__(**lowerCamelCase       )

   if text_config is None:
     __A		:     Tuple												=		{}
     logger.info("""text_config is None. Initializing the OwlViTTextConfig with default values."""       )

   if vision_config is None:
     __A		:     Optional[int]												=		{}
     logger.info("""vision_config is None. initializing the OwlViTVisionConfig with default values."""       )

   __A		:     str												=		OwlViTTextConfig(**lowerCamelCase       )
   __A		:     Dict												=		OwlViTVisionConfig(**lowerCamelCase       )

   __A		:     List[Any]												=		projection_dim
   __A		:     int												=		logit_scale_init_value
   __A		:     str												=		return_dict
   __A		:     str												=		1.0
 @classmethod
 def 		lowercase_(   cls			:    Union[str, Any]				,   lowerCamelCase			:    Union[str, os.PathLike]				,   **lowerCamelCase			:    Optional[int]       ):



   """simple docstring"""





   cls._set_token_in_kwargs(lowerCamelCase       )

   __A							,					__A		:     List[str]												=		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 		lowercase_(   cls			:    Dict				,   lowerCamelCase			:    Dict				,   lowerCamelCase			:    Dict				,   **lowerCamelCase			:    Tuple       ):



   """simple docstring"""





   __A		:     str												=		{}
   __A		:     int												=		text_config
   __A		:     Optional[int]												=		vision_config

   return cls.from_dict(lowerCamelCase				,   **lowerCamelCase       )






 def 		lowercase_(   self			:    Optional[Any]       ):



   """simple docstring"""





   __A		:     Optional[Any]												=		copy.deepcopy(self.__dict__       )
   __A		:     Union[str, Any]												=		self.text_config.to_dict()
   __A		:     List[str]												=		self.vision_config.to_dict()
   __A		:     str												=		self.__class__.model_type
   return output







class  __A				( _SCREAMING_SNAKE_CASE			):
 @property
 def 		lowercase_(   self			:    int       ):



   """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 		lowercase_(   self			:    Optional[int]       ):



   """simple docstring"""





   return OrderedDict(
       [
           ("""logits_per_image""", {0: """batch"""}),
           ("""logits_per_text""", {0: """batch"""}),
           ("""text_embeds""", {0: """batch"""}),
           ("""image_embeds""", {0: """batch"""}),
       ]       )
 @property
 def 		lowercase_(   self			:    List[str]       ):



   """simple docstring"""





   return 1e-4
 def 		lowercase_(   self			:    Any				,   lowerCamelCase			:    "ProcessorMixin"				,   lowerCamelCase			:    int = -1				,   lowerCamelCase			:    int = -1				,   lowerCamelCase			:    Optional["TensorType"] = None				,   ):



   """simple docstring"""





   __A		:     Dict												=		super().generate_dummy_inputs(
       processor.tokenizer				,   batch_size=lowerCamelCase				,   seq_length=lowerCamelCase				,   framework=lowerCamelCase       )
   __A		:     List[Any]												=		super().generate_dummy_inputs(
       processor.image_processor				,   batch_size=lowerCamelCase				,   framework=lowerCamelCase       )
   return {**text_input_dict, **image_input_dict}






 @property
 def 		lowercase_(   self			:    Dict       ):



   """simple docstring"""





   return 14





'''simple docstring'''
from ...configuration_utils import PretrainedConfig
from ...utils import logging


A__   :		int 		=logging.get_logger(__name__)

A__   :		Union[str, Any] 		={
    'facebook/dpr-ctx_encoder-single-nq-base': (
        'https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/main/config.json'
    ),
    'facebook/dpr-question_encoder-single-nq-base': (
        'https://huggingface.co/facebook/dpr-question_encoder-single-nq-base/resolve/main/config.json'
    ),
    'facebook/dpr-reader-single-nq-base': (
        'https://huggingface.co/facebook/dpr-reader-single-nq-base/resolve/main/config.json'
    ),
    'facebook/dpr-ctx_encoder-multiset-base': (
        'https://huggingface.co/facebook/dpr-ctx_encoder-multiset-base/resolve/main/config.json'
    ),
    'facebook/dpr-question_encoder-multiset-base': (
        'https://huggingface.co/facebook/dpr-question_encoder-multiset-base/resolve/main/config.json'
    ),
    'facebook/dpr-reader-multiset-base': (
        'https://huggingface.co/facebook/dpr-reader-multiset-base/resolve/main/config.json'
    ),
}







class  __A				( _SCREAMING_SNAKE_CASE			):
 lowerCamelCase				       ='''dpr'''
 def __init__(   self			:    Optional[int]				,   lowerCamelCase			:    Tuple=3_05_22				,   lowerCamelCase			:    List[str]=7_68				,   lowerCamelCase			:    Union[str, Any]=12				,   lowerCamelCase			:    Tuple=12				,   lowerCamelCase			:    Dict=30_72				,   lowerCamelCase			:    List[Any]="gelu"				,   lowerCamelCase			:    List[Any]=0.1				,   lowerCamelCase			:    Union[str, Any]=0.1				,   lowerCamelCase			:    Optional[Any]=5_12				,   lowerCamelCase			:    List[Any]=2				,   lowerCamelCase			:    int=0.02				,   lowerCamelCase			:    Union[str, Any]=1e-1_2				,   lowerCamelCase			:    int=0				,   lowerCamelCase			:    List[str]="absolute"				,   lowerCamelCase			:    int = 0				,   **lowerCamelCase			:    List[Any]				,   ):



   """simple docstring"""





   super().__init__(pad_token_id=lowerCamelCase				,   **lowerCamelCase       )

   __A		:     Dict												=		vocab_size
   __A		:     int												=		hidden_size
   __A		:     str												=		num_hidden_layers
   __A		:     Union[str, Any]												=		num_attention_heads
   __A		:     Union[str, Any]												=		hidden_act
   __A		:     Optional[Any]												=		intermediate_size
   __A		:     str												=		hidden_dropout_prob
   __A		:     int												=		attention_probs_dropout_prob
   __A		:     int												=		max_position_embeddings
   __A		:     Dict												=		type_vocab_size
   __A		:     Dict												=		initializer_range
   __A		:     Union[str, Any]												=		layer_norm_eps
   __A		:     int												=		projection_dim
   __A		:     List[Any]												=		position_embedding_type



