





'''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        =						logging.get_logger(__name__)

a        =						{
    "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 (   _snake_case			):
   __UpperCamelCase   : Optional[Any]	      =	'owlvit_text_model'





   def __init__(					self				:			Dict				,lowerCamelCase				:			Optional[int]=4_9408				,lowerCamelCase				:			List[Any]=512				,lowerCamelCase				:			Dict=2048				,lowerCamelCase				:			str=12				,lowerCamelCase				:			Tuple=8				,lowerCamelCase				:			int=16				,lowerCamelCase				:			Optional[int]="quick_gelu"				,lowerCamelCase				:			int=1E-5				,lowerCamelCase				:			str=0.0				,lowerCamelCase				:			Tuple=0.02				,lowerCamelCase				:			str=1.0				,lowerCamelCase				:			Union[str, Any]=0				,lowerCamelCase				:			Optional[int]=4_9406				,lowerCamelCase				:			Dict=4_9407				,**lowerCamelCase				:			Tuple				,):

      '''simple docstring'''

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

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





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

      '''simple docstring'''

      cls._set_token_in_kwargs(lowerCamelCase    )

      __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE      							=       cls.get_config_dict(lowerCamelCase				,**lowerCamelCase    )

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





   def __init__(					self				:			Optional[Any]				,lowerCamelCase				:			List[str]=768				,lowerCamelCase				:			Any=3072				,lowerCamelCase				:			Dict=12				,lowerCamelCase				:			str=12				,lowerCamelCase				:			Union[str, Any]=3				,lowerCamelCase				:			Dict=768				,lowerCamelCase				:			List[Any]=32				,lowerCamelCase				:			int="quick_gelu"				,lowerCamelCase				:			int=1E-5				,lowerCamelCase				:			str=0.0				,lowerCamelCase				:			str=0.02				,lowerCamelCase				:			Union[str, Any]=1.0				,**lowerCamelCase				:			Any				,):

      '''simple docstring'''

      super().__init__(**lowerCamelCase    )

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





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

      '''simple docstring'''

      cls._set_token_in_kwargs(lowerCamelCase    )

      __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE      							=       cls.get_config_dict(lowerCamelCase				,**lowerCamelCase    )

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





   def __init__(					self				:			Optional[int]				,lowerCamelCase				:			Tuple=None				,lowerCamelCase				:			Optional[Any]=None				,lowerCamelCase				:			int=512				,lowerCamelCase				:			Union[str, Any]=2.6_592				,lowerCamelCase				:			List[Any]=True				,**lowerCamelCase				:			List[str]				,):

      '''simple docstring'''

      super().__init__(**lowerCamelCase    )

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

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

      __SCREAMING_SNAKE_CASE      							=       OwlViTTextConfig(**lowerCamelCase    )
      __SCREAMING_SNAKE_CASE      							=       OwlViTVisionConfig(**lowerCamelCase    )

      __SCREAMING_SNAKE_CASE      							=       projection_dim
      __SCREAMING_SNAKE_CASE      							=       logit_scale_init_value
      __SCREAMING_SNAKE_CASE      							=       return_dict
      __SCREAMING_SNAKE_CASE      							=       1.0





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

      '''simple docstring'''

      cls._set_token_in_kwargs(lowerCamelCase    )

      __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE      							=       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      UpperCAmelCase__     (					cls				:			int				,lowerCamelCase				:			Dict				,lowerCamelCase				:			Dict				,**lowerCamelCase				:			Any    ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE      							=       {}
      __SCREAMING_SNAKE_CASE      							=       text_config
      __SCREAMING_SNAKE_CASE      							=       vision_config

      return cls.from_dict(lowerCamelCase				,**lowerCamelCase    )





   def      UpperCAmelCase__     (					self				:			Any    ):

      '''simple docstring'''

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







class __a (   _snake_case			):





   @property
   def      UpperCAmelCase__     (					self				:			List[Any]    ):

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

      '''simple docstring'''

      return 1E-4





   def      UpperCAmelCase__     (					self				:			int				,lowerCamelCase				:			"ProcessorMixin"				,lowerCamelCase				:			int = -1				,lowerCamelCase				:			int = -1				,lowerCamelCase				:			Optional["TensorType"] = None				,):

      '''simple docstring'''

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





   @property
   def      UpperCAmelCase__     (					self				:			str    ):

      '''simple docstring'''

      return 14












'''simple docstring'''

from ...utils import (
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_torch_available,
    is_transformers_available,
)


try:
    if not (is_transformers_available() and is_torch_available()):
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
    from .multicontrolnet import MultiControlNetModel
    from .pipeline_controlnet import StableDiffusionControlNetPipeline
    from .pipeline_controlnet_imgaimg import StableDiffusionControlNetImgaImgPipeline
    from .pipeline_controlnet_inpaint import StableDiffusionControlNetInpaintPipeline


if is_transformers_available() and is_flax_available():
    from .pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline





