



"""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       UpperCamelCase__			(   _lowerCAmelCase      ):

			"""simple docstring"""


			A__	:					Any							  =     "owlvit_text_model"


			def __init__(      self						,	SCREAMING_SNAKE_CASE__=49408						,	SCREAMING_SNAKE_CASE__=512						,	SCREAMING_SNAKE_CASE__=2048						,	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__=49406						,	SCREAMING_SNAKE_CASE__=49407						,	**SCREAMING_SNAKE_CASE__						,	)      ->	Dict:
				super().__init__(pad_token_id=SCREAMING_SNAKE_CASE__						,	bos_token_id=SCREAMING_SNAKE_CASE__						,	eos_token_id=SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)

				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   snake_case__	(      cls						,	SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)      ->	"PretrainedConfig":
				cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__		)

				A__							,							A__											=					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":
					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(SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)






class       UpperCamelCase__			(   _lowerCAmelCase      ):

			"""simple docstring"""


			A__	:					str							  =     "owlvit_vision_model"


			def __init__(      self						,	SCREAMING_SNAKE_CASE__=768						,	SCREAMING_SNAKE_CASE__=3072						,	SCREAMING_SNAKE_CASE__=12						,	SCREAMING_SNAKE_CASE__=12						,	SCREAMING_SNAKE_CASE__=3						,	SCREAMING_SNAKE_CASE__=768						,	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__						,	)      ->	Optional[Any]:
				super().__init__(**SCREAMING_SNAKE_CASE__		)

				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   snake_case__	(      cls						,	SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)      ->	"PretrainedConfig":
				cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__		)

				A__							,							A__											=					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":
					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(SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)






class       UpperCamelCase__			(   _lowerCAmelCase      ):

			"""simple docstring"""


			A__	:					Optional[Any]							  =     "owlvit"
			A__	:					Dict							  =     True


			def __init__(      self						,	SCREAMING_SNAKE_CASE__=None						,	SCREAMING_SNAKE_CASE__=None						,	SCREAMING_SNAKE_CASE__=512						,	SCREAMING_SNAKE_CASE__=2.6_5_9_2						,	SCREAMING_SNAKE_CASE__=True						,	**SCREAMING_SNAKE_CASE__						,	)      ->	Optional[int]:
				super().__init__(**SCREAMING_SNAKE_CASE__		)

				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(**SCREAMING_SNAKE_CASE__		)
				A__											=					OwlViTVisionConfig(**SCREAMING_SNAKE_CASE__		)

				A__											=					projection_dim
				A__											=					logit_scale_init_value
				A__											=					return_dict
				A__											=					1.0


			@classmethod
			def   snake_case__	(      cls						,	SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)      ->	"PretrainedConfig":
				cls._set_token_in_kwargs(SCREAMING_SNAKE_CASE__		)

				A__							,							A__											=					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   snake_case__	(      cls						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)      ->	Any:
				A__											=					{}
				A__											=					text_config
				A__											=					vision_config

				return cls.from_dict(SCREAMING_SNAKE_CASE__						,	**SCREAMING_SNAKE_CASE__		)







			def   snake_case__	(      self		)      ->	int:
				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       UpperCamelCase__			(   _lowerCAmelCase      ):

			"""simple docstring"""


			@property
			def   snake_case__	(      self		)      ->	Mapping[str, Mapping[int, str]]:
				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		)      ->	Mapping[str, Mapping[int, str]]:
				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		)      ->	float:
				return 1e-4


			def   snake_case__	(      self						,	SCREAMING_SNAKE_CASE__						,	SCREAMING_SNAKE_CASE__ = -1						,	SCREAMING_SNAKE_CASE__ = -1						,	SCREAMING_SNAKE_CASE__ = None						,	)      ->	Mapping[str, Any]:
				A__											=					super().generate_dummy_inputs(
				    processor.tokenizer						,	batch_size=SCREAMING_SNAKE_CASE__						,	seq_length=SCREAMING_SNAKE_CASE__						,	framework=SCREAMING_SNAKE_CASE__		)
				A__											=					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   snake_case__	(      self		)      ->	int:
				return 14









"""simple docstring"""







from ..utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_scipy_available,
    is_torch_available,
    is_torchsde_available,
)


try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			from ..utils.dummy_pt_objects import *  # noqa F403
else:
			from .scheduling_consistency_models import CMStochasticIterativeScheduler
			from .scheduling_ddim import DDIMScheduler
			from .scheduling_ddim_inverse import DDIMInverseScheduler
			from .scheduling_ddim_parallel import DDIMParallelScheduler
			from .scheduling_ddpm import DDPMScheduler
			from .scheduling_ddpm_parallel import DDPMParallelScheduler
			from .scheduling_deis_multistep import DEISMultistepScheduler
			from .scheduling_dpmsolver_multistep import DPMSolverMultistepScheduler
			from .scheduling_dpmsolver_multistep_inverse import DPMSolverMultistepInverseScheduler
			from .scheduling_dpmsolver_singlestep import DPMSolverSinglestepScheduler
			from .scheduling_euler_ancestral_discrete import EulerAncestralDiscreteScheduler
			from .scheduling_euler_discrete import EulerDiscreteScheduler
			from .scheduling_heun_discrete import HeunDiscreteScheduler
			from .scheduling_ipndm import IPNDMScheduler
			from .scheduling_k_dpm_2_ancestral_discrete import KDPMaAncestralDiscreteScheduler
			from .scheduling_k_dpm_2_discrete import KDPMaDiscreteScheduler
			from .scheduling_karras_ve import KarrasVeScheduler
			from .scheduling_pndm import PNDMScheduler
			from .scheduling_repaint import RePaintScheduler
			from .scheduling_sde_ve import ScoreSdeVeScheduler
			from .scheduling_sde_vp import ScoreSdeVpScheduler
			from .scheduling_unclip import UnCLIPScheduler
			from .scheduling_unipc_multistep import UniPCMultistepScheduler
			from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin
			from .scheduling_vq_diffusion import VQDiffusionScheduler

try:
			if not is_flax_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			from ..utils.dummy_flax_objects import *  # noqa F403
else:
			from .scheduling_ddim_flax import FlaxDDIMScheduler
			from .scheduling_ddpm_flax import FlaxDDPMScheduler
			from .scheduling_dpmsolver_multistep_flax import FlaxDPMSolverMultistepScheduler
			from .scheduling_karras_ve_flax import FlaxKarrasVeScheduler
			from .scheduling_lms_discrete_flax import FlaxLMSDiscreteScheduler
			from .scheduling_pndm_flax import FlaxPNDMScheduler
			from .scheduling_sde_ve_flax import FlaxScoreSdeVeScheduler
			from .scheduling_utils_flax import (
			    FlaxKarrasDiffusionSchedulers,
			    FlaxSchedulerMixin,
			    FlaxSchedulerOutput,
			    broadcast_to_shape_from_left,
			)


try:
			if not (is_torch_available() and is_scipy_available()):
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			from ..utils.dummy_torch_and_scipy_objects import *  # noqa F403
else:
			from .scheduling_lms_discrete import LMSDiscreteScheduler

try:
			if not (is_torch_available() and is_torchsde_available()):
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			from ..utils.dummy_torch_and_torchsde_objects import *  # noqa F403
else:
			from .scheduling_dpmsolver_sde import DPMSolverSDEScheduler




