



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


__lowerCAmelCase							:       List[Any]          =       logging.get_logger(__name__)

__lowerCAmelCase							:       str          =       {
    '''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  _lowerCAmelCase     (					SCREAMING_SNAKE_CASE__		):





		"""simple docstring"""






		_lowerCamelCase      	=							'''owlvit_text_model'''





		def __init__(       self				,     _lowercase=4_9_4_0_8				,     _lowercase=5_1_2				,     _lowercase=2_0_4_8				,     _lowercase=1_2				,     _lowercase=8				,     _lowercase=1_6				,     _lowercase="quick_gelu"				,     _lowercase=1E-5				,     _lowercase=0.0				,     _lowercase=0.02				,     _lowercase=1.0				,     _lowercase=0				,     _lowercase=4_9_4_0_6				,     _lowercase=4_9_4_0_7				,     **_lowercase				,     )			->    str:







								'''simple docstring'''

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

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





		@classmethod
		def  UpperCAmelCase__				(       cls				,     _lowercase				,     **_lowercase )			->    "PretrainedConfig":







								'''simple docstring'''

								cls._set_token_in_kwargs(_lowercase )

								snake_case_      ,		snake_case_ :			Union[str, Any]            =      cls.get_config_dict(_lowercase				,     **_lowercase )

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




class  _lowerCAmelCase     (					SCREAMING_SNAKE_CASE__		):





		"""simple docstring"""






		_lowerCamelCase      	=							'''owlvit_vision_model'''





		def __init__(       self				,     _lowercase=7_6_8				,     _lowercase=3_0_7_2				,     _lowercase=1_2				,     _lowercase=1_2				,     _lowercase=3				,     _lowercase=7_6_8				,     _lowercase=3_2				,     _lowercase="quick_gelu"				,     _lowercase=1E-5				,     _lowercase=0.0				,     _lowercase=0.02				,     _lowercase=1.0				,     **_lowercase				,     )			->    Dict:







								'''simple docstring'''

								super().__init__(**_lowercase )

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





		@classmethod
		def  UpperCAmelCase__				(       cls				,     _lowercase				,     **_lowercase )			->    "PretrainedConfig":







								'''simple docstring'''

								cls._set_token_in_kwargs(_lowercase )

								snake_case_      ,		snake_case_ :			int            =      cls.get_config_dict(_lowercase				,     **_lowercase )

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




class  _lowerCAmelCase     (					SCREAMING_SNAKE_CASE__		):





		"""simple docstring"""






		_lowerCamelCase      	=							'''owlvit'''
		_lowerCamelCase      	=							True





		def __init__(       self				,     _lowercase=None				,     _lowercase=None				,     _lowercase=5_1_2				,     _lowercase=2.6592				,     _lowercase=True				,     **_lowercase				,     )			->    Optional[Any]:







								'''simple docstring'''

								super().__init__(**_lowercase )

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

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

								snake_case_ :			Optional[int]            =      OwlViTTextConfig(**_lowercase )
								snake_case_ :			Optional[int]            =      OwlViTVisionConfig(**_lowercase )

								snake_case_ :			Union[str, Any]            =      projection_dim
								snake_case_ :			str            =      logit_scale_init_value
								snake_case_ :			int            =      return_dict
								snake_case_ :			List[str]            =      1.0





		@classmethod
		def  UpperCAmelCase__				(       cls				,     _lowercase				,     **_lowercase )			->    "PretrainedConfig":







								'''simple docstring'''

								cls._set_token_in_kwargs(_lowercase )

								snake_case_      ,		snake_case_ :			List[str]            =      cls.get_config_dict(_lowercase				,     **_lowercase )

								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(_lowercase				,     **_lowercase )





		@classmethod
		def  UpperCAmelCase__				(       cls				,     _lowercase				,     _lowercase				,     **_lowercase )			->    Optional[Any]:







								'''simple docstring'''

								snake_case_ :			List[str]            =      {}
								snake_case_ :			List[str]            =      text_config
								snake_case_ :			Any            =      vision_config

								return cls.from_dict(_lowercase				,     **_lowercase )





		def  UpperCAmelCase__				(       self )			->    List[Any]:







								'''simple docstring'''

								snake_case_ :			List[Any]            =      copy.deepcopy(self.__dict__ )
								snake_case_ :			Dict            =      self.text_config.to_dict()
								snake_case_ :			Optional[int]            =      self.vision_config.to_dict()
								snake_case_ :			int            =      self.__class__.model_type
								return output




class  _lowerCAmelCase     (					SCREAMING_SNAKE_CASE__		):





		"""simple docstring"""






		@property
		def  UpperCAmelCase__				(       self )			->    Mapping[str, Mapping[int, str]]:







								'''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 )			->    Mapping[str, Mapping[int, str]]:







								'''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 )			->    float:







								'''simple docstring'''

								return 1E-4





		def  UpperCAmelCase__				(       self				,     _lowercase				,     _lowercase = -1				,     _lowercase = -1				,     _lowercase = None				,     )			->    Mapping[str, Any]:







								'''simple docstring'''

								snake_case_ :			Any            =      super().generate_dummy_inputs(
								    processor.tokenizer				,     batch_size=_lowercase				,     seq_length=_lowercase				,     framework=_lowercase )
								snake_case_ :			Any            =      super().generate_dummy_inputs(
								    processor.image_processor				,     batch_size=_lowercase				,     framework=_lowercase )
								return {**text_input_dict, **image_input_dict}





		@property
		def  UpperCAmelCase__				(       self )			->    int:







								'''simple docstring'''

								return 1_4









from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


A__      :     Optional[int]       =					{
    'configuration_clap': [
        'CLAP_PRETRAINED_MODEL_ARCHIVE_LIST',
        'ClapAudioConfig',
        'ClapConfig',
        'ClapTextConfig',
    ],
    'processing_clap': ['ClapProcessor'],
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							A__      :     str       =					[
							    'CLAP_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'ClapModel',
							    'ClapPreTrainedModel',
							    'ClapTextModel',
							    'ClapTextModelWithProjection',
							    'ClapAudioModel',
							    'ClapAudioModelWithProjection',
							]
							A__      :     List[Any]       =					['ClapFeatureExtractor']

if TYPE_CHECKING:
							from .configuration_clap import (
							    CLAP_PRETRAINED_MODEL_ARCHIVE_LIST,
							    ClapAudioConfig,
							    ClapConfig,
							    ClapTextConfig,
							)
							from .processing_clap import ClapProcessor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .feature_extraction_clap import ClapFeatureExtractor
														from .modeling_clap import (
														    CLAP_PRETRAINED_MODEL_ARCHIVE_LIST,
														    ClapAudioModel,
														    ClapAudioModelWithProjection,
														    ClapModel,
														    ClapPreTrainedModel,
														    ClapTextModel,
														    ClapTextModelWithProjection,
														)


else:
							import sys

							A__      :     int       =					_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




