
"""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 			_SCREAMING_SNAKE_CASE					(			A__							):
			UpperCAmelCase_  :Dict				 =						"owlvit_text_model"






			def __init__(					self       ,   __A=4_9408       ,   __A=512       ,   __A=2048       ,   __A=12       ,   __A=8       ,   __A=16       ,   __A="quick_gelu"       ,   __A=1E-5       ,   __A=0.0       ,   __A=0.0_2       ,   __A=1.0       ,   __A=0       ,   __A=4_9406       ,   __A=4_9407       ,   **__A       ,   )			->     Union[str, Any]:
						super().__init__(pad_token_id=__A       ,   bos_token_id=__A       ,   eos_token_id=__A       ,   **__A       )

						lowerCAmelCase_    :List[str]			     =  vocab_size
						lowerCAmelCase_    :Dict			     =  hidden_size
						lowerCAmelCase_    :str			     =  intermediate_size
						lowerCAmelCase_    :str			     =  num_hidden_layers
						lowerCAmelCase_    :int			     =  num_attention_heads
						lowerCAmelCase_    :Any			     =  max_position_embeddings
						lowerCAmelCase_    :List[str]			     =  hidden_act
						lowerCAmelCase_    :str			     =  layer_norm_eps
						lowerCAmelCase_    :Any			     =  attention_dropout
						lowerCAmelCase_    :str			     =  initializer_range
						lowerCAmelCase_    :str			     =  initializer_factor






			@classmethod
			def  __lowerCAmelCase (					cls       ,   __A       ,   **__A       )			->     "PretrainedConfig":
						cls._set_token_in_kwargs(__A       )

						lowerCAmelCase_     ,       lowerCAmelCase_    :Optional[Any]			     =  cls.get_config_dict(__A       ,   **__A       )

						# get the text config dict if we are loading from OwlViTConfig
						if config_dict.get("""model_type"""       ) == "owlvit":
									lowerCAmelCase_    :Optional[int]			     =  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 			_SCREAMING_SNAKE_CASE					(			A__							):
			UpperCAmelCase_  :str				 =						"owlvit_vision_model"






			def __init__(					self       ,   __A=768       ,   __A=3072       ,   __A=12       ,   __A=12       ,   __A=3       ,   __A=768       ,   __A=32       ,   __A="quick_gelu"       ,   __A=1E-5       ,   __A=0.0       ,   __A=0.0_2       ,   __A=1.0       ,   **__A       ,   )			->     Any:
						super().__init__(**__A       )

						lowerCAmelCase_    :int			     =  hidden_size
						lowerCAmelCase_    :Optional[int]			     =  intermediate_size
						lowerCAmelCase_    :Dict			     =  num_hidden_layers
						lowerCAmelCase_    :int			     =  num_attention_heads
						lowerCAmelCase_    :Optional[int]			     =  num_channels
						lowerCAmelCase_    :Any			     =  image_size
						lowerCAmelCase_    :Union[str, Any]			     =  patch_size
						lowerCAmelCase_    :Optional[int]			     =  hidden_act
						lowerCAmelCase_    :int			     =  layer_norm_eps
						lowerCAmelCase_    :Tuple			     =  attention_dropout
						lowerCAmelCase_    :Tuple			     =  initializer_range
						lowerCAmelCase_    :Dict			     =  initializer_factor






			@classmethod
			def  __lowerCAmelCase (					cls       ,   __A       ,   **__A       )			->     "PretrainedConfig":
						cls._set_token_in_kwargs(__A       )

						lowerCAmelCase_     ,       lowerCAmelCase_    :Optional[Any]			     =  cls.get_config_dict(__A       ,   **__A       )

						# get the vision config dict if we are loading from OwlViTConfig
						if config_dict.get("""model_type"""       ) == "owlvit":
									lowerCAmelCase_    :List[Any]			     =  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 			_SCREAMING_SNAKE_CASE					(			A__							):
			UpperCAmelCase_  :str				 =						"owlvit"
			UpperCAmelCase_  :int				 =						True






			def __init__(					self       ,   __A=None       ,   __A=None       ,   __A=512       ,   __A=2.6_5_9_2       ,   __A=True       ,   **__A       ,   )			->     Tuple:
						super().__init__(**__A       )

						if text_config is None:
									lowerCAmelCase_    :Optional[Any]			     =  {}
									logger.info("""text_config is None. Initializing the OwlViTTextConfig with default values."""       )

						if vision_config is None:
									lowerCAmelCase_    :List[Any]			     =  {}
									logger.info("""vision_config is None. initializing the OwlViTVisionConfig with default values."""       )

						lowerCAmelCase_    :Tuple			     =  OwlViTTextConfig(**__A       )
						lowerCAmelCase_    :Dict			     =  OwlViTVisionConfig(**__A       )

						lowerCAmelCase_    :Any			     =  projection_dim
						lowerCAmelCase_    :int			     =  logit_scale_init_value
						lowerCAmelCase_    :List[str]			     =  return_dict
						lowerCAmelCase_    :Optional[int]			     =  1.0






			@classmethod
			def  __lowerCAmelCase (					cls       ,   __A       ,   **__A       )			->     "PretrainedConfig":
						cls._set_token_in_kwargs(__A       )

						lowerCAmelCase_     ,       lowerCAmelCase_    :Optional[int]			     =  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  __lowerCAmelCase (					cls       ,   __A       ,   __A       ,   **__A       )			->     Optional[int]:
						lowerCAmelCase_    :Optional[int]			     =  {}
						lowerCAmelCase_    :int			     =  text_config
						lowerCAmelCase_    :Dict			     =  vision_config

						return cls.from_dict(__A       ,   **__A       )






			def  __lowerCAmelCase (					self       )			->     Any:
						lowerCAmelCase_    :List[Any]			     =  copy.deepcopy(self.__dict__       )
						lowerCAmelCase_    :str			     =  self.text_config.to_dict()
						lowerCAmelCase_    :Tuple			     =  self.vision_config.to_dict()
						lowerCAmelCase_    :Optional[int]			     =  self.__class__.model_type
						return output




class 			_SCREAMING_SNAKE_CASE					(			A__							):






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






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






			@property
			def  __lowerCAmelCase (					self       )			->     int:
						return 14












from typing import TYPE_CHECKING

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


lowerCamelCase				:		Optional[Any]     =   {
    "configuration_whisper": ["WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP", "WhisperConfig", "WhisperOnnxConfig"],
    "feature_extraction_whisper": ["WhisperFeatureExtractor"],
    "processing_whisper": ["WhisperProcessor"],
    "tokenization_whisper": ["WhisperTokenizer"],
}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:		Tuple     =   ["WhisperTokenizerFast"]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:		str     =   [
     "WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST",
     "WhisperForConditionalGeneration",
     "WhisperModel",
     "WhisperPreTrainedModel",
     "WhisperForAudioClassification",
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:		List[str]     =   [
     "TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST",
     "TFWhisperForConditionalGeneration",
     "TFWhisperModel",
     "TFWhisperPreTrainedModel",
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:		str     =   [
     "FlaxWhisperForConditionalGeneration",
     "FlaxWhisperModel",
     "FlaxWhisperPreTrainedModel",
     "FlaxWhisperForAudioClassification",
 ]


if TYPE_CHECKING:
 from .configuration_whisper import WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP, WhisperConfig, WhisperOnnxConfig
 from .feature_extraction_whisper import WhisperFeatureExtractor
 from .processing_whisper import WhisperProcessor
 from .tokenization_whisper import WhisperTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_whisper_fast import WhisperTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_whisper import (
      WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
      WhisperForAudioClassification,
      WhisperForConditionalGeneration,
      WhisperModel,
      WhisperPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_whisper import (
      TF_WHISPER_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFWhisperForConditionalGeneration,
      TFWhisperModel,
      TFWhisperPreTrainedModel,
  )

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_whisper import (
      FlaxWhisperForAudioClassification,
      FlaxWhisperForConditionalGeneration,
      FlaxWhisperModel,
      FlaxWhisperPreTrainedModel,
  )

else:
 import sys

 lowerCamelCase				:		Tuple     =   _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



