





"""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 					_SCREAMING_SNAKE_CASE(   A  ):
       SCREAMING_SNAKE_CASE_   :      Any							=  '''owlvit_text_model'''




       def __init__(						self		,SCREAMING_SNAKE_CASE__=4_94_08		,SCREAMING_SNAKE_CASE__=5_12		,SCREAMING_SNAKE_CASE__=20_48		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=8		,SCREAMING_SNAKE_CASE__=16		,SCREAMING_SNAKE_CASE__="quick_gelu"		,SCREAMING_SNAKE_CASE__=1E-5		,SCREAMING_SNAKE_CASE__=0.0		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=1.0		,SCREAMING_SNAKE_CASE__=0		,SCREAMING_SNAKE_CASE__=4_94_06		,SCREAMING_SNAKE_CASE__=4_94_07		,**SCREAMING_SNAKE_CASE__		,)			->      List[Any]:





             """simple docstring"""






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

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




       @classmethod
       def     _UpperCamelCase     (						cls		,SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)			->      "PretrainedConfig":





             """simple docstring"""






             cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :List[Any]						=  cls.get_config_dict(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)

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






class 					_SCREAMING_SNAKE_CASE(   A  ):
       SCREAMING_SNAKE_CASE_   :      Tuple							=  '''owlvit_vision_model'''




       def __init__(						self		,SCREAMING_SNAKE_CASE__=7_68		,SCREAMING_SNAKE_CASE__=30_72		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=3		,SCREAMING_SNAKE_CASE__=7_68		,SCREAMING_SNAKE_CASE__=32		,SCREAMING_SNAKE_CASE__="quick_gelu"		,SCREAMING_SNAKE_CASE__=1E-5		,SCREAMING_SNAKE_CASE__=0.0		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=1.0		,**SCREAMING_SNAKE_CASE__		,)			->      List[str]:





             """simple docstring"""






             super().__init__(**SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE   :Optional[int]						=  hidden_size
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  intermediate_size
             __SCREAMING_SNAKE_CASE   :Any						=  num_hidden_layers
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  num_attention_heads
             __SCREAMING_SNAKE_CASE   :Any						=  num_channels
             __SCREAMING_SNAKE_CASE   :List[str]						=  image_size
             __SCREAMING_SNAKE_CASE   :Tuple						=  patch_size
             __SCREAMING_SNAKE_CASE   :Any						=  hidden_act
             __SCREAMING_SNAKE_CASE   :List[Any]						=  layer_norm_eps
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  attention_dropout
             __SCREAMING_SNAKE_CASE   :int						=  initializer_range
             __SCREAMING_SNAKE_CASE   :List[str]						=  initializer_factor




       @classmethod
       def     _UpperCamelCase     (						cls		,SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)			->      "PretrainedConfig":





             """simple docstring"""






             cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :int						=  cls.get_config_dict(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)

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






class 					_SCREAMING_SNAKE_CASE(   A  ):
       SCREAMING_SNAKE_CASE_   :      Optional[int]							=  '''owlvit'''
       SCREAMING_SNAKE_CASE_   :      str							=  True




       def __init__(						self		,SCREAMING_SNAKE_CASE__=None		,SCREAMING_SNAKE_CASE__=None		,SCREAMING_SNAKE_CASE__=5_12		,SCREAMING_SNAKE_CASE__=2.6_5_9_2		,SCREAMING_SNAKE_CASE__=True		,**SCREAMING_SNAKE_CASE__		,)			->      Optional[Any]:





             """simple docstring"""






             super().__init__(**SCREAMING_SNAKE_CASE__							)

             if text_config is None:
                   __SCREAMING_SNAKE_CASE   :Optional[int]						=  {}
                   logger.info('''text_config is None. Initializing the OwlViTTextConfig with default values.'''							)

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

             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  OwlViTTextConfig(**SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :str						=  OwlViTVisionConfig(**SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE   :Optional[int]						=  projection_dim
             __SCREAMING_SNAKE_CASE   :Tuple						=  logit_scale_init_value
             __SCREAMING_SNAKE_CASE   :int						=  return_dict
             __SCREAMING_SNAKE_CASE   :List[str]						=  1.0




       @classmethod
       def     _UpperCamelCase     (						cls		,SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)			->      "PretrainedConfig":





             """simple docstring"""






             cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__							)

             __SCREAMING_SNAKE_CASE				,__SCREAMING_SNAKE_CASE   :List[Any]						=  cls.get_config_dict(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)

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




       @classmethod
       def     _UpperCamelCase     (						cls		,SCREAMING_SNAKE_CASE__		,SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)			->      Dict:





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :Optional[int]						=  {}
             __SCREAMING_SNAKE_CASE   :int						=  text_config
             __SCREAMING_SNAKE_CASE   :Dict						=  vision_config

             return cls.from_dict(SCREAMING_SNAKE_CASE__		,**SCREAMING_SNAKE_CASE__							)




       def     _UpperCamelCase     (						self							)			->      str:





             """simple docstring"""






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






class 					_SCREAMING_SNAKE_CASE(   A  ):




       @property
       def     _UpperCamelCase     (						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     _UpperCamelCase     (						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     _UpperCamelCase     (						self							)			->      float:





             """simple docstring"""






             return 1E-4




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





             """simple docstring"""






             __SCREAMING_SNAKE_CASE   :str						=  super().generate_dummy_inputs(
                 processor.tokenizer		,batch_size=SCREAMING_SNAKE_CASE__		,seq_length=SCREAMING_SNAKE_CASE__		,framework=SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :Tuple						=  super().generate_dummy_inputs(
                 processor.image_processor		,batch_size=SCREAMING_SNAKE_CASE__		,framework=SCREAMING_SNAKE_CASE__							)
             return {**text_input_dict, **image_input_dict}




       @property
       def     _UpperCamelCase     (						self							)			->      int:





             """simple docstring"""






             return 14






"""simple docstring"""
from collections import OrderedDict
from typing import Mapping

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


lowerCamelCase_								=		logging.get_logger(__name__)

lowerCamelCase_								=		{
    "facebook/xmod-base": "https://huggingface.co/facebook/xmod-base/resolve/main/config.json",
    "facebook/xmod-large-prenorm": "https://huggingface.co/facebook/xmod-large-prenorm/resolve/main/config.json",
    "facebook/xmod-base-13-125k": "https://huggingface.co/facebook/xmod-base-13-125k/resolve/main/config.json",
    "facebook/xmod-base-30-125k": "https://huggingface.co/facebook/xmod-base-30-125k/resolve/main/config.json",
    "facebook/xmod-base-30-195k": "https://huggingface.co/facebook/xmod-base-30-195k/resolve/main/config.json",
    "facebook/xmod-base-60-125k": "https://huggingface.co/facebook/xmod-base-60-125k/resolve/main/config.json",
    "facebook/xmod-base-60-265k": "https://huggingface.co/facebook/xmod-base-60-265k/resolve/main/config.json",
    "facebook/xmod-base-75-125k": "https://huggingface.co/facebook/xmod-base-75-125k/resolve/main/config.json",
    "facebook/xmod-base-75-269k": "https://huggingface.co/facebook/xmod-base-75-269k/resolve/main/config.json",
}






class 					_SCREAMING_SNAKE_CASE(   A  ):
       SCREAMING_SNAKE_CASE_   :      Any							=  '''xmod'''




       def __init__(						self		,SCREAMING_SNAKE_CASE__=3_05_22		,SCREAMING_SNAKE_CASE__=7_68		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=12		,SCREAMING_SNAKE_CASE__=30_72		,SCREAMING_SNAKE_CASE__="gelu"		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=0.1		,SCREAMING_SNAKE_CASE__=5_12		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=0.0_2		,SCREAMING_SNAKE_CASE__=1E-12		,SCREAMING_SNAKE_CASE__=1		,SCREAMING_SNAKE_CASE__=0		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__="absolute"		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=None		,SCREAMING_SNAKE_CASE__=False		,SCREAMING_SNAKE_CASE__=2		,SCREAMING_SNAKE_CASE__=False		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=True		,SCREAMING_SNAKE_CASE__=("en_XX",)		,SCREAMING_SNAKE_CASE__=None		,**SCREAMING_SNAKE_CASE__		,)			->      Optional[Any]:





             """simple docstring"""






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

             __SCREAMING_SNAKE_CASE   :Optional[int]						=  vocab_size
             __SCREAMING_SNAKE_CASE   :List[Any]						=  hidden_size
             __SCREAMING_SNAKE_CASE   :List[str]						=  num_hidden_layers
             __SCREAMING_SNAKE_CASE   :List[str]						=  num_attention_heads
             __SCREAMING_SNAKE_CASE   :Optional[int]						=  hidden_act
             __SCREAMING_SNAKE_CASE   :Tuple						=  intermediate_size
             __SCREAMING_SNAKE_CASE   :Dict						=  hidden_dropout_prob
             __SCREAMING_SNAKE_CASE   :str						=  attention_probs_dropout_prob
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  max_position_embeddings
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  type_vocab_size
             __SCREAMING_SNAKE_CASE   :str						=  initializer_range
             __SCREAMING_SNAKE_CASE   :List[Any]						=  layer_norm_eps
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  position_embedding_type
             __SCREAMING_SNAKE_CASE   :Any						=  use_cache
             __SCREAMING_SNAKE_CASE   :List[str]						=  classifier_dropout
             __SCREAMING_SNAKE_CASE   :Any						=  pre_norm
             __SCREAMING_SNAKE_CASE   :Dict						=  adapter_reduction_factor
             __SCREAMING_SNAKE_CASE   :Dict						=  adapter_layer_norm
             __SCREAMING_SNAKE_CASE   :Dict						=  adapter_reuse_layer_norm
             __SCREAMING_SNAKE_CASE   :Tuple						=  ln_before_adapter
             __SCREAMING_SNAKE_CASE   :Any						=  list(SCREAMING_SNAKE_CASE__							)
             __SCREAMING_SNAKE_CASE   :Optional[Any]						=  default_language






class 					_SCREAMING_SNAKE_CASE(   A  ):




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





             """simple docstring"""






             if self.task == "multiple-choice":
                   __SCREAMING_SNAKE_CASE   :Tuple						=  {0: '''batch''', 1: '''choice''', 2: '''sequence'''}
             else:
                   __SCREAMING_SNAKE_CASE   :Union[str, Any]						=  {0: '''batch''', 1: '''sequence'''}
             return OrderedDict(
                 [
                     ('''input_ids''', dynamic_axis),
                     ('''attention_mask''', dynamic_axis),
                 ]							)