





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


UpperCamelCase_									=logging.get_logger(__name__)

UpperCamelCase_									={
    """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						(				_lowerCAmelCase    ):
				UpperCamelCase								=   '''owlvit_text_model'''






				def __init__(			self		:   Union[str, Any],			lowerCAmelCase__		:   int=4_9_4_0_8,			lowerCAmelCase__		:   str=5_1_2,			lowerCAmelCase__		:   Any=2_0_4_8,			lowerCAmelCase__		:   List[str]=1_2,			lowerCAmelCase__		:   int=8,			lowerCAmelCase__		:   Tuple=1_6,			lowerCAmelCase__		:   List[Any]="quick_gelu",			lowerCAmelCase__		:   Union[str, Any]=1e-5,			lowerCAmelCase__		:   List[Any]=0.0,			lowerCAmelCase__		:   List[Any]=0.02,			lowerCAmelCase__		:   str=1.0,			lowerCAmelCase__		:   Optional[int]=0,			lowerCAmelCase__		:   Dict=4_9_4_0_6,			lowerCAmelCase__		:   int=4_9_4_0_7,			**lowerCAmelCase__		:   Dict,			)     ->				str:




										'''simple docstring'''



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

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






				@classmethod
				def     snake_case     (			cls		:   List[str],			lowerCAmelCase__		:   Union[str, os.PathLike],			**lowerCAmelCase__		:   Optional[Any]							)     ->				"PretrainedConfig":




										'''simple docstring'''



										cls._set_token_in_kwargs(lowerCAmelCase__							)

										_UpperCamelCase       ,							_UpperCamelCase      : Union[str, Any]         =   cls.get_config_dict(lowerCAmelCase__,			**lowerCAmelCase__							)

										# get the text config dict if we are loading from OwlViTConfig
										if config_dict.get('''model_type'''							) == "owlvit":
																_UpperCamelCase      : 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						(				_lowerCAmelCase    ):
				UpperCamelCase								=   '''owlvit_vision_model'''






				def __init__(			self		:   Optional[Any],			lowerCAmelCase__		:   Tuple=7_6_8,			lowerCAmelCase__		:   Dict=3_0_7_2,			lowerCAmelCase__		:   Optional[int]=1_2,			lowerCAmelCase__		:   Any=1_2,			lowerCAmelCase__		:   Any=3,			lowerCAmelCase__		:   Union[str, Any]=7_6_8,			lowerCAmelCase__		:   int=3_2,			lowerCAmelCase__		:   List[Any]="quick_gelu",			lowerCAmelCase__		:   Optional[Any]=1e-5,			lowerCAmelCase__		:   Optional[Any]=0.0,			lowerCAmelCase__		:   Union[str, Any]=0.02,			lowerCAmelCase__		:   Union[str, Any]=1.0,			**lowerCAmelCase__		:   List[str],			)     ->				Union[str, Any]:




										'''simple docstring'''



										super().__init__(**lowerCAmelCase__							)

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






				@classmethod
				def     snake_case     (			cls		:   Tuple,			lowerCAmelCase__		:   Union[str, os.PathLike],			**lowerCAmelCase__		:   Any							)     ->				"PretrainedConfig":




										'''simple docstring'''



										cls._set_token_in_kwargs(lowerCAmelCase__							)

										_UpperCamelCase       ,							_UpperCamelCase      : Any         =   cls.get_config_dict(lowerCAmelCase__,			**lowerCAmelCase__							)

										# get the vision config dict if we are loading from OwlViTConfig
										if config_dict.get('''model_type'''							) == "owlvit":
																_UpperCamelCase      : Tuple         =   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						(				_lowerCAmelCase    ):
				UpperCamelCase								=   '''owlvit'''
				UpperCamelCase								=   True






				def __init__(			self		:   Union[str, Any],			lowerCAmelCase__		:   int=None,			lowerCAmelCase__		:   str=None,			lowerCAmelCase__		:   Optional[int]=5_1_2,			lowerCAmelCase__		:   Tuple=2.6_592,			lowerCAmelCase__		:   List[str]=True,			**lowerCAmelCase__		:   Any,			)     ->				Union[str, Any]:




										'''simple docstring'''



										super().__init__(**lowerCAmelCase__							)

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

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

										_UpperCamelCase      : List[Any]         =   OwlViTTextConfig(**lowerCAmelCase__							)
										_UpperCamelCase      : Any         =   OwlViTVisionConfig(**lowerCAmelCase__							)

										_UpperCamelCase      : Optional[Any]         =   projection_dim
										_UpperCamelCase      : Optional[Any]         =   logit_scale_init_value
										_UpperCamelCase      : Union[str, Any]         =   return_dict
										_UpperCamelCase      : Union[str, Any]         =   1.0






				@classmethod
				def     snake_case     (			cls		:   int,			lowerCAmelCase__		:   Union[str, os.PathLike],			**lowerCAmelCase__		:   str							)     ->				"PretrainedConfig":




										'''simple docstring'''



										cls._set_token_in_kwargs(lowerCAmelCase__							)

										_UpperCamelCase       ,							_UpperCamelCase      : int         =   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		:   int,			lowerCAmelCase__		:   Dict,			lowerCAmelCase__		:   Dict,			**lowerCAmelCase__		:   Union[str, Any]							)     ->				Dict:




										'''simple docstring'''



										_UpperCamelCase      : Dict         =   {}
										_UpperCamelCase      : int         =   text_config
										_UpperCamelCase      : Union[str, Any]         =   vision_config

										return cls.from_dict(lowerCAmelCase__,			**lowerCAmelCase__							)






				def     snake_case     (			self		:   List[Any]							)     ->				Dict:




										'''simple docstring'''



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




class 			_a						(				_lowerCAmelCase    ):






				@property
				def     snake_case     (			self		:   str							)     ->				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     snake_case     (			self		:   List[Any]							)     ->				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     snake_case     (			self		:   List[str]							)     ->				float:




										'''simple docstring'''



										return 1e-4






				def     snake_case     (			self		:   Optional[int],			lowerCAmelCase__		:   "ProcessorMixin",			lowerCAmelCase__		:   int = -1,			lowerCAmelCase__		:   int = -1,			lowerCAmelCase__		:   Optional["TensorType"] = None,			)     ->				Mapping[str, Any]:




										'''simple docstring'''



										_UpperCamelCase      : int         =   super().generate_dummy_inputs(
										    processor.tokenizer,			batch_size=lowerCAmelCase__,			seq_length=lowerCAmelCase__,			framework=lowerCAmelCase__							)
										_UpperCamelCase      : Optional[int]         =   super().generate_dummy_inputs(
										    processor.image_processor,			batch_size=lowerCAmelCase__,			framework=lowerCAmelCase__							)
										return {**text_input_dict, **image_input_dict}






				@property
				def     snake_case     (			self		:   Any							)     ->				int:




										'''simple docstring'''



										return 1_4










"""simple docstring"""




import logging

from transformers.configuration_utils import PretrainedConfig


UpperCamelCase_									=logging.getLogger(__name__)




class 			_a						(				_lowerCAmelCase    ):
				UpperCamelCase								=   '''masked_bert'''






				def __init__(			self		:   Optional[Any],			lowerCAmelCase__		:   Dict=3_0_5_2_2,			lowerCAmelCase__		:   int=7_6_8,			lowerCAmelCase__		:   Tuple=1_2,			lowerCAmelCase__		:   Optional[Any]=1_2,			lowerCAmelCase__		:   Tuple=3_0_7_2,			lowerCAmelCase__		:   Optional[int]="gelu",			lowerCAmelCase__		:   Tuple=0.1,			lowerCAmelCase__		:   Tuple=0.1,			lowerCAmelCase__		:   Any=5_1_2,			lowerCAmelCase__		:   Optional[int]=2,			lowerCAmelCase__		:   Optional[int]=0.02,			lowerCAmelCase__		:   Union[str, Any]=1e-1_2,			lowerCAmelCase__		:   Union[str, Any]=0,			lowerCAmelCase__		:   Dict="topK",			lowerCAmelCase__		:   Union[str, Any]="constant",			lowerCAmelCase__		:   Union[str, Any]=0.0,			**lowerCAmelCase__		:   Any,			)     ->				List[Any]:




										'''simple docstring'''



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

										_UpperCamelCase      : Optional[Any]         =   vocab_size
										_UpperCamelCase      : int         =   hidden_size
										_UpperCamelCase      : List[Any]         =   num_hidden_layers
										_UpperCamelCase      : Any         =   num_attention_heads
										_UpperCamelCase      : List[str]         =   hidden_act
										_UpperCamelCase      : Tuple         =   intermediate_size
										_UpperCamelCase      : int         =   hidden_dropout_prob
										_UpperCamelCase      : str         =   attention_probs_dropout_prob
										_UpperCamelCase      : Optional[int]         =   max_position_embeddings
										_UpperCamelCase      : str         =   type_vocab_size
										_UpperCamelCase      : Optional[Any]         =   initializer_range
										_UpperCamelCase      : List[str]         =   layer_norm_eps
										_UpperCamelCase      : int         =   pruning_method
										_UpperCamelCase      : Union[str, Any]         =   mask_init
										_UpperCamelCase      : Any         =   mask_scale



