
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        lowerCAmelCase__      (   __lowercase	):
						UpperCamelCase_							: Any	=		'owlvit_text_model'

						def __init__(			self       ,							a=4_94_08       ,							a=5_12       ,							a=20_48       ,							a=12       ,							a=8       ,							a=16       ,							a="quick_gelu"       ,							a=1e-5       ,							a=0.0       ,							a=0.02       ,							a=1.0       ,							a=0       ,							a=4_94_06       ,							a=4_94_07       ,							**a       ,							)					->      Any:


								'''simple docstring'''

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

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







						@classmethod
						def  A_				(			cls       ,							a       ,							**a				)					->      "PretrainedConfig":


								'''simple docstring'''

								cls._set_token_in_kwargs(__A				)

								_UpperCamelCase    ,	_UpperCamelCase						    =	cls.get_config_dict(__A       ,							**__A				)

								# get the text config dict if we are loading from OwlViTConfig
								if config_dict.get("""model_type"""				) == "owlvit":
										_UpperCamelCase						    =	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        lowerCAmelCase__      (   __lowercase	):
						UpperCamelCase_							: Optional[int]	=		'owlvit_vision_model'

						def __init__(			self       ,							a=7_68       ,							a=30_72       ,							a=12       ,							a=12       ,							a=3       ,							a=7_68       ,							a=32       ,							a="quick_gelu"       ,							a=1e-5       ,							a=0.0       ,							a=0.02       ,							a=1.0       ,							**a       ,							)					->      Dict:


								'''simple docstring'''

								super().__init__(**__A				)

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







						@classmethod
						def  A_				(			cls       ,							a       ,							**a				)					->      "PretrainedConfig":


								'''simple docstring'''

								cls._set_token_in_kwargs(__A				)

								_UpperCamelCase    ,	_UpperCamelCase						    =	cls.get_config_dict(__A       ,							**__A				)

								# get the vision config dict if we are loading from OwlViTConfig
								if config_dict.get("""model_type"""				) == "owlvit":
										_UpperCamelCase						    =	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        lowerCAmelCase__      (   __lowercase	):
						UpperCamelCase_							: Optional[int]	=		'owlvit'
						UpperCamelCase_							: Optional[int]	=		True

						def __init__(			self       ,							a=None       ,							a=None       ,							a=5_12       ,							a=2.6592       ,							a=True       ,							**a       ,							)					->      Optional[int]:


								'''simple docstring'''

								super().__init__(**__A				)

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

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

								_UpperCamelCase						    =	OwlViTTextConfig(**__A				)
								_UpperCamelCase						    =	OwlViTVisionConfig(**__A				)

								_UpperCamelCase						    =	projection_dim
								_UpperCamelCase						    =	logit_scale_init_value
								_UpperCamelCase						    =	return_dict
								_UpperCamelCase						    =	1.0

						@classmethod
						def  A_				(			cls       ,							a       ,							**a				)					->      "PretrainedConfig":


								'''simple docstring'''

								cls._set_token_in_kwargs(__A				)

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


								'''simple docstring'''

								_UpperCamelCase						    =	{}
								_UpperCamelCase						    =	text_config
								_UpperCamelCase						    =	vision_config

								return cls.from_dict(__A       ,							**__A				)







						def  A_				(			self				)					->      Union[str, Any]:


								'''simple docstring'''

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







class        lowerCAmelCase__      (   __lowercase	):

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

								_UpperCamelCase						    =	super().generate_dummy_inputs(
								    processor.tokenizer       ,							batch_size=__A       ,							seq_length=__A       ,							framework=__A				)
								_UpperCamelCase						    =	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





lowerCamelCase__	=							[
    "DownloadConfig",
    "DownloadManager",
    "DownloadMode",
    "StreamingDownloadManager",
]

from .download_config import DownloadConfig
from .download_manager import DownloadManager, DownloadMode
from .streaming_download_manager import StreamingDownloadManager



