




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


SCREAMING_SNAKE_CASE_	     =       logging.get_logger(__name__)

SCREAMING_SNAKE_CASE_	     =       {
    '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 				snake_case_			(					_UpperCAmelCase			):







   """simple docstring"""




   A_				      =       '''owlvit_text_model'''







   def __init__(		self       ,					lowerCamelCase_=4_9_4_0_8       ,					lowerCamelCase_=5_1_2       ,					lowerCamelCase_=2_0_4_8       ,					lowerCamelCase_=1_2       ,					lowerCamelCase_=8       ,					lowerCamelCase_=1_6       ,					lowerCamelCase_="quick_gelu"       ,					lowerCamelCase_=1e-5       ,					lowerCamelCase_=0.0       ,					lowerCamelCase_=0.02       ,					lowerCamelCase_=1.0       ,					lowerCamelCase_=0       ,					lowerCamelCase_=4_9_4_0_6       ,					lowerCamelCase_=4_9_4_0_7       ,					**lowerCamelCase_       ,					)				->   Tuple:
       super().__init__(pad_token_id=lowerCamelCase_       ,					bos_token_id=lowerCamelCase_       ,					eos_token_id=lowerCamelCase_       ,					**lowerCamelCase_)

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

       UpperCamelCase       ,	UpperCamelCase              =	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              =	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 				snake_case_			(					_UpperCAmelCase			):







   """simple docstring"""




   A_				      =       '''owlvit_vision_model'''







   def __init__(		self       ,					lowerCamelCase_=7_6_8       ,					lowerCamelCase_=3_0_7_2       ,					lowerCamelCase_=1_2       ,					lowerCamelCase_=1_2       ,					lowerCamelCase_=3       ,					lowerCamelCase_=7_6_8       ,					lowerCamelCase_=3_2       ,					lowerCamelCase_="quick_gelu"       ,					lowerCamelCase_=1e-5       ,					lowerCamelCase_=0.0       ,					lowerCamelCase_=0.02       ,					lowerCamelCase_=1.0       ,					**lowerCamelCase_       ,					)				->   int:
       super().__init__(**lowerCamelCase_)

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

       UpperCamelCase       ,	UpperCamelCase              =	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              =	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 				snake_case_			(					_UpperCAmelCase			):







   """simple docstring"""




   A_				      =       '''owlvit'''
   A_				      =       True







   def __init__(		self       ,					lowerCamelCase_=None       ,					lowerCamelCase_=None       ,					lowerCamelCase_=5_1_2       ,					lowerCamelCase_=2.6592       ,					lowerCamelCase_=True       ,					**lowerCamelCase_       ,					)				->   Tuple:
       super().__init__(**lowerCamelCase_)

       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(**lowerCamelCase_)
       UpperCamelCase              =	OwlViTVisionConfig(**lowerCamelCase_)

       UpperCamelCase              =	projection_dim
       UpperCamelCase              =	logit_scale_init_value
       UpperCamelCase              =	return_dict
       UpperCamelCase              =	1.0







   @classmethod
   def   UpperCAmelCase__			(		cls       ,					lowerCamelCase_       ,					**lowerCamelCase_)				->   "PretrainedConfig":
       cls._set_token_in_kwargs(lowerCamelCase_)

       UpperCamelCase       ,	UpperCamelCase              =	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       ,					lowerCamelCase_       ,					lowerCamelCase_       ,					**lowerCamelCase_)				->   Optional[Any]:
       UpperCamelCase              =	{}
       UpperCamelCase              =	text_config
       UpperCamelCase              =	vision_config

       return cls.from_dict(lowerCamelCase_       ,					**lowerCamelCase_)







   def   UpperCAmelCase__			(		self)				->   Any:
       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 				snake_case_			(					_UpperCAmelCase			):







   """simple docstring"""




   @property
   def   UpperCAmelCase__			(		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   UpperCAmelCase__			(		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   UpperCAmelCase__			(		self)				->   float:
       return 1e-4







   def   UpperCAmelCase__			(		self       ,					lowerCamelCase_       ,					lowerCamelCase_ = -1       ,					lowerCamelCase_ = -1       ,					lowerCamelCase_ = None       ,					)				->   Mapping[str, Any]:
       UpperCamelCase              =	super().generate_dummy_inputs(
           processor.tokenizer       ,					batch_size=lowerCamelCase_       ,					seq_length=lowerCamelCase_       ,					framework=lowerCamelCase_)
       UpperCamelCase              =	super().generate_dummy_inputs(
           processor.image_processor       ,					batch_size=lowerCamelCase_       ,					framework=lowerCamelCase_)
       return {**text_input_dict, **image_input_dict}







   @property
   def   UpperCAmelCase__			(		self)				->   int:
       return 1_4






"""simple docstring"""





from . import __version__

# Backward compatibility imports, to make sure all those objects can be found in file_utils
from .utils import (
    CLOUDFRONT_DISTRIB_PREFIX,
    CONFIG_NAME,
    DISABLE_TELEMETRY,
    DUMMY_INPUTS,
    DUMMY_MASK,
    ENV_VARS_TRUE_AND_AUTO_VALUES,
    ENV_VARS_TRUE_VALUES,
    FEATURE_EXTRACTOR_NAME,
    FLAX_WEIGHTS_NAME,
    HF_MODULES_CACHE,
    HUGGINGFACE_CO_PREFIX,
    HUGGINGFACE_CO_RESOLVE_ENDPOINT,
    MODEL_CARD_NAME,
    MULTIPLE_CHOICE_DUMMY_INPUTS,
    PYTORCH_PRETRAINED_BERT_CACHE,
    PYTORCH_TRANSFORMERS_CACHE,
    S3_BUCKET_PREFIX,
    SENTENCEPIECE_UNDERLINE,
    SPIECE_UNDERLINE,
    TF2_WEIGHTS_NAME,
    TF_WEIGHTS_NAME,
    TORCH_FX_REQUIRED_VERSION,
    TRANSFORMERS_CACHE,
    TRANSFORMERS_DYNAMIC_MODULE_NAME,
    USE_JAX,
    USE_TF,
    USE_TORCH,
    WEIGHTS_INDEX_NAME,
    WEIGHTS_NAME,
    ContextManagers,
    DummyObject,
    EntryNotFoundError,
    ExplicitEnum,
    ModelOutput,
    PaddingStrategy,
    PushToHubMixin,
    RepositoryNotFoundError,
    RevisionNotFoundError,
    TensorType,
    _LazyModule,
    add_code_sample_docstrings,
    add_end_docstrings,
    add_start_docstrings,
    add_start_docstrings_to_model_forward,
    cached_property,
    copy_func,
    default_cache_path,
    define_sagemaker_information,
    get_cached_models,
    get_file_from_repo,
    get_full_repo_name,
    get_torch_version,
    has_file,
    http_user_agent,
    is_apex_available,
    is_bsa_available,
    is_coloredlogs_available,
    is_datasets_available,
    is_detectrona_available,
    is_faiss_available,
    is_flax_available,
    is_ftfy_available,
    is_in_notebook,
    is_ipex_available,
    is_librosa_available,
    is_offline_mode,
    is_onnx_available,
    is_pandas_available,
    is_phonemizer_available,
    is_protobuf_available,
    is_psutil_available,
    is_pyanvml_available,
    is_pyctcdecode_available,
    is_pytesseract_available,
    is_pytorch_quantization_available,
    is_rjieba_available,
    is_sagemaker_dp_enabled,
    is_sagemaker_mp_enabled,
    is_scipy_available,
    is_sentencepiece_available,
    is_seqio_available,
    is_sklearn_available,
    is_soundfile_availble,
    is_spacy_available,
    is_speech_available,
    is_tensor,
    is_tensorflow_probability_available,
    is_tfaonnx_available,
    is_tf_available,
    is_timm_available,
    is_tokenizers_available,
    is_torch_available,
    is_torch_bfaa_available,
    is_torch_cuda_available,
    is_torch_fx_available,
    is_torch_fx_proxy,
    is_torch_mps_available,
    is_torch_tfaa_available,
    is_torch_tpu_available,
    is_torchaudio_available,
    is_training_run_on_sagemaker,
    is_vision_available,
    replace_return_docstrings,
    requires_backends,
    to_numpy,
    to_py_obj,
    torch_only_method,
)






