




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

_lowerCamelCase     :		Dict								=       {
    """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     UpperCamelCase_   (			UpperCAmelCase__					):

    '''simple docstring'''






    UpperCAmelCase__							  =				'''owlvit_text_model'''


    def __init__(      self				:     Dict ,			UpperCAmelCase__				:     Optional[int]=49_408 ,			UpperCAmelCase__				:     Optional[int]=512 ,			UpperCAmelCase__				:     List[str]=2_048 ,			UpperCAmelCase__				:     str=12 ,			UpperCAmelCase__				:     Union[str, Any]=8 ,			UpperCAmelCase__				:     Tuple=16 ,			UpperCAmelCase__				:     Union[str, Any]="quick_gelu" ,			UpperCAmelCase__				:     str=1e-5 ,			UpperCAmelCase__				:     Optional[Any]=0.0 ,			UpperCAmelCase__				:     Optional[Any]=0.02 ,			UpperCAmelCase__				:     str=1.0 ,			UpperCAmelCase__				:     int=0 ,			UpperCAmelCase__				:     str=49_406 ,			UpperCAmelCase__				:     List[str]=49_407 ,			**UpperCAmelCase__				:     str ,			)						->int:





           '''simple docstring'''

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

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





    @classmethod
    def 	SCREAMING_SNAKE_CASE							(      cls				:     List[Any] ,			UpperCAmelCase__				:     Union[str, os.PathLike] ,			**UpperCAmelCase__				:     Tuple)						->"PretrainedConfig":





           '''simple docstring'''

           cls._set_token_in_kwargs(__UpperCAmelCase)

           A__			,							A__							=   cls.get_config_dict(__UpperCAmelCase ,			**__UpperCAmelCase)

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


class     UpperCamelCase_   (			UpperCAmelCase__					):

    '''simple docstring'''






    UpperCAmelCase__							  =				'''owlvit_vision_model'''


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





           '''simple docstring'''

           super().__init__(**__UpperCAmelCase)

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





    @classmethod
    def 	SCREAMING_SNAKE_CASE							(      cls				:     Any ,			UpperCAmelCase__				:     Union[str, os.PathLike] ,			**UpperCAmelCase__				:     Dict)						->"PretrainedConfig":





           '''simple docstring'''

           cls._set_token_in_kwargs(__UpperCAmelCase)

           A__			,							A__							=   cls.get_config_dict(__UpperCAmelCase ,			**__UpperCAmelCase)

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


class     UpperCamelCase_   (			UpperCAmelCase__					):

    '''simple docstring'''






    UpperCAmelCase__							  =				'''owlvit'''
    UpperCAmelCase__							  =				True


    def __init__(      self				:     List[str] ,			UpperCAmelCase__				:     Optional[int]=None ,			UpperCAmelCase__				:     Tuple=None ,			UpperCAmelCase__				:     List[Any]=512 ,			UpperCAmelCase__				:     Tuple=2.6592 ,			UpperCAmelCase__				:     Optional[int]=True ,			**UpperCAmelCase__				:     List[Any] ,			)						->List[Any]:





           '''simple docstring'''

           super().__init__(**__UpperCAmelCase)

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

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

           A__							=   OwlViTTextConfig(**__UpperCAmelCase)
           A__							=   OwlViTVisionConfig(**__UpperCAmelCase)

           A__							=   projection_dim
           A__							=   logit_scale_init_value
           A__							=   return_dict
           A__							=   1.0


    @classmethod
    def 	SCREAMING_SNAKE_CASE							(      cls				:     Any ,			UpperCAmelCase__				:     Union[str, os.PathLike] ,			**UpperCAmelCase__				:     Union[str, Any])						->"PretrainedConfig":





           '''simple docstring'''

           cls._set_token_in_kwargs(__UpperCAmelCase)

           A__			,							A__							=   cls.get_config_dict(__UpperCAmelCase ,			**__UpperCAmelCase)

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


    @classmethod
    def 	SCREAMING_SNAKE_CASE							(      cls				:     str ,			UpperCAmelCase__				:     Dict ,			UpperCAmelCase__				:     Dict ,			**UpperCAmelCase__				:     List[str])						->str:





           '''simple docstring'''

           A__							=   {}
           A__							=   text_config
           A__							=   vision_config

           return cls.from_dict(__UpperCAmelCase ,			**__UpperCAmelCase)





    def 	SCREAMING_SNAKE_CASE							(      self				:     Optional[Any])						->List[str]:





           '''simple docstring'''

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


class     UpperCamelCase_   (			UpperCAmelCase__					):

    '''simple docstring'''






    @property
    def 	SCREAMING_SNAKE_CASE							(      self				:     Optional[Any])						->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 	SCREAMING_SNAKE_CASE							(      self				:     Optional[int])						->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 	SCREAMING_SNAKE_CASE							(      self				:     int)						->float:





           '''simple docstring'''

           return 1e-4


    def 	SCREAMING_SNAKE_CASE							(      self				:     str ,			UpperCAmelCase__				:     "ProcessorMixin" ,			UpperCAmelCase__				:     int = -1 ,			UpperCAmelCase__				:     int = -1 ,			UpperCAmelCase__				:     Optional["TensorType"] = None ,			)						->Mapping[str, Any]:





           '''simple docstring'''

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





    @property
    def 	SCREAMING_SNAKE_CASE							(      self				:     List[str])						->int:





           '''simple docstring'''

           return 14








from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


_lowerCamelCase     :		Union[str, Any]								=       {
    """configuration_swiftformer""": [
        """SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """SwiftFormerConfig""",
        """SwiftFormerOnnxConfig""",
    ]
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  _lowerCamelCase     :		Union[str, Any]								=       [
      """SWIFTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
      """SwiftFormerForImageClassification""",
      """SwiftFormerModel""",
      """SwiftFormerPreTrainedModel""",
  ]

if TYPE_CHECKING:
  from .configuration_swiftformer import (
      SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
      SwiftFormerConfig,
      SwiftFormerOnnxConfig,
  )

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_swiftformer import (
        SWIFTFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        SwiftFormerForImageClassification,
        SwiftFormerModel,
        SwiftFormerPreTrainedModel,
    )

else:
  import sys

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


