





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

lowerCAmelCase							:       Union[str, Any]					 =	{
    "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			):
				SCREAMING_SNAKE_CASE__     :   Union[str, Any]		      =     '''owlvit_text_model'''






				def __init__(  self			, _lowerCAmelCase=49408			, _lowerCAmelCase=512			, _lowerCAmelCase=2048			, _lowerCAmelCase=12			, _lowerCAmelCase=8			, _lowerCAmelCase=16			, _lowerCAmelCase="quick_gelu"			, _lowerCAmelCase=1e-5			, _lowerCAmelCase=0.0			, _lowerCAmelCase=0.02			, _lowerCAmelCase=1.0			, _lowerCAmelCase=0			, _lowerCAmelCase=49406			, _lowerCAmelCase=49407			, **_lowerCAmelCase			, ):

										"""simple docstring"""




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

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






				@classmethod
				def 			snake_case_    (  cls			, _lowerCAmelCase			, **_lowerCAmelCase					):

										"""simple docstring"""




										cls._set_token_in_kwargs(snake_case_					)

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

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





class 				a			(      __snake_case			):
				SCREAMING_SNAKE_CASE__     :   Tuple		      =     '''owlvit_vision_model'''






				def __init__(  self			, _lowerCAmelCase=768			, _lowerCAmelCase=3072			, _lowerCAmelCase=12			, _lowerCAmelCase=12			, _lowerCAmelCase=3			, _lowerCAmelCase=768			, _lowerCAmelCase=32			, _lowerCAmelCase="quick_gelu"			, _lowerCAmelCase=1e-5			, _lowerCAmelCase=0.0			, _lowerCAmelCase=0.02			, _lowerCAmelCase=1.0			, **_lowerCAmelCase			, ):

										"""simple docstring"""




										super().__init__(**snake_case_					)

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






				@classmethod
				def 			snake_case_    (  cls			, _lowerCAmelCase			, **_lowerCAmelCase					):

										"""simple docstring"""




										cls._set_token_in_kwargs(snake_case_					)

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

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





class 				a			(      __snake_case			):
				SCREAMING_SNAKE_CASE__     :   Optional[int]		      =     '''owlvit'''
				SCREAMING_SNAKE_CASE__     :   Any		      =     True






				def __init__(  self			, _lowerCAmelCase=None			, _lowerCAmelCase=None			, _lowerCAmelCase=512			, _lowerCAmelCase=2.6592			, _lowerCAmelCase=True			, **_lowerCAmelCase			, ):

										"""simple docstring"""




										super().__init__(**snake_case_					)

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

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

										__SCREAMING_SNAKE_CASE:				Union[str, Any]           =   OwlViTTextConfig(**snake_case_					)
										__SCREAMING_SNAKE_CASE:				Optional[int]           =   OwlViTVisionConfig(**snake_case_					)

										__SCREAMING_SNAKE_CASE:				Any           =   projection_dim
										__SCREAMING_SNAKE_CASE:				Tuple           =   logit_scale_init_value
										__SCREAMING_SNAKE_CASE:				List[Any]           =   return_dict
										__SCREAMING_SNAKE_CASE:				Dict           =   1.0






				@classmethod
				def 			snake_case_    (  cls			, _lowerCAmelCase			, **_lowerCAmelCase					):

										"""simple docstring"""




										cls._set_token_in_kwargs(snake_case_					)

										__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE:				List[Any]           =   cls.get_config_dict(snake_case_			, **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(snake_case_			, **snake_case_					)






				@classmethod
				def 			snake_case_    (  cls			, _lowerCAmelCase			, _lowerCAmelCase			, **_lowerCAmelCase					):

										"""simple docstring"""




										__SCREAMING_SNAKE_CASE:				Any           =   {}
										__SCREAMING_SNAKE_CASE:				int           =   text_config
										__SCREAMING_SNAKE_CASE:				Dict           =   vision_config

										return cls.from_dict(snake_case_			, **snake_case_					)






				def 			snake_case_    (  self					):

										"""simple docstring"""




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





class 				a			(      __snake_case			):






				@property
				def 			snake_case_    (  self					):

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

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

										"""simple docstring"""




										return 1e-4






				def 			snake_case_    (  self			, _lowerCAmelCase			, _lowerCAmelCase = -1			, _lowerCAmelCase = -1			, _lowerCAmelCase = None			, ):

										"""simple docstring"""




										__SCREAMING_SNAKE_CASE:				Tuple           =   super().generate_dummy_inputs(
										    processor.tokenizer			, batch_size=snake_case_			, seq_length=snake_case_			, framework=snake_case_					)
										__SCREAMING_SNAKE_CASE:				Union[str, Any]           =   super().generate_dummy_inputs(
										    processor.image_processor			, batch_size=snake_case_			, framework=snake_case_					)
										return {**text_input_dict, **image_input_dict}






				@property
				def 			snake_case_    (  self					):

										"""simple docstring"""




										return 14










from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__A							:			Dict         =			{
    "configuration_blenderbot": [
        "BLENDERBOT_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "BlenderbotConfig",
        "BlenderbotOnnxConfig",
    ],
    "tokenization_blenderbot": ["BlenderbotTokenizer"],
}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A							:			str         =			["BlenderbotTokenizerFast"]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A							:			str         =			[
     "BLENDERBOT_PRETRAINED_MODEL_ARCHIVE_LIST",
     "BlenderbotForCausalLM",
     "BlenderbotForConditionalGeneration",
     "BlenderbotModel",
     "BlenderbotPreTrainedModel",
 ]


try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A							:			Union[str, Any]         =			[
     "TFBlenderbotForConditionalGeneration",
     "TFBlenderbotModel",
     "TFBlenderbotPreTrainedModel",
 ]


try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A							:			Optional[Any]         =			[
     "FlaxBlenderbotForConditionalGeneration",
     "FlaxBlenderbotModel",
     "FlaxBlenderbotPreTrainedModel",
 ]


if TYPE_CHECKING:
 from .configuration_blenderbot import (
     BLENDERBOT_PRETRAINED_CONFIG_ARCHIVE_MAP,
     BlenderbotConfig,
     BlenderbotOnnxConfig,
 )
 from .tokenization_blenderbot import BlenderbotTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_blenderbot_fast import BlenderbotTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_blenderbot import (
      BLENDERBOT_PRETRAINED_MODEL_ARCHIVE_LIST,
      BlenderbotForCausalLM,
      BlenderbotForConditionalGeneration,
      BlenderbotModel,
      BlenderbotPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_blenderbot import (
      TFBlenderbotForConditionalGeneration,
      TFBlenderbotModel,
      TFBlenderbotPreTrainedModel,
  )

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_blenderbot import (
      FlaxBlenderbotForConditionalGeneration,
      FlaxBlenderbotModel,
      FlaxBlenderbotPreTrainedModel,
  )

else:
 import sys

 __A							:			str         =			_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





