






'''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        a_		(    lowerCamelCase       ):
  lowercase  	=   """owlvit_text_model"""

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



        """simple docstring"""






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

        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 						A__		(   cls    ,	_SCREAMING_SNAKE_CASE    ,	**_SCREAMING_SNAKE_CASE   )						->   "PretrainedConfig":



        """simple docstring"""






        cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE   )

        UpperCamelCase						,UpperCamelCase       						=      cls.get_config_dict(_SCREAMING_SNAKE_CASE    ,	**_SCREAMING_SNAKE_CASE   )

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






class        a_		(    lowerCamelCase       ):
  lowercase  	=   """owlvit_vision_model"""

  def __init__(   self    ,	_SCREAMING_SNAKE_CASE=768    ,	_SCREAMING_SNAKE_CASE=3072    ,	_SCREAMING_SNAKE_CASE=12    ,	_SCREAMING_SNAKE_CASE=12    ,	_SCREAMING_SNAKE_CASE=3    ,	_SCREAMING_SNAKE_CASE=768    ,	_SCREAMING_SNAKE_CASE=32    ,	_SCREAMING_SNAKE_CASE="quick_gelu"    ,	_SCREAMING_SNAKE_CASE=1e-5    ,	_SCREAMING_SNAKE_CASE=0.0    ,	_SCREAMING_SNAKE_CASE=0.0_2    ,	_SCREAMING_SNAKE_CASE=1.0    ,	**_SCREAMING_SNAKE_CASE    ,	)						->   List[Any]:



        """simple docstring"""






        super().__init__(**_SCREAMING_SNAKE_CASE   )

        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 						A__		(   cls    ,	_SCREAMING_SNAKE_CASE    ,	**_SCREAMING_SNAKE_CASE   )						->   "PretrainedConfig":



        """simple docstring"""






        cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE   )

        UpperCamelCase						,UpperCamelCase       						=      cls.get_config_dict(_SCREAMING_SNAKE_CASE    ,	**_SCREAMING_SNAKE_CASE   )

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






class        a_		(    lowerCamelCase       ):
  lowercase  	=   """owlvit"""
  lowercase  	=   True

  def __init__(   self    ,	_SCREAMING_SNAKE_CASE=None    ,	_SCREAMING_SNAKE_CASE=None    ,	_SCREAMING_SNAKE_CASE=512    ,	_SCREAMING_SNAKE_CASE=2.6_5_9_2    ,	_SCREAMING_SNAKE_CASE=True    ,	**_SCREAMING_SNAKE_CASE    ,	)						->   List[str]:



        """simple docstring"""






        super().__init__(**_SCREAMING_SNAKE_CASE   )

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

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

  @classmethod
  def 						A__		(   cls    ,	_SCREAMING_SNAKE_CASE    ,	**_SCREAMING_SNAKE_CASE   )						->   "PretrainedConfig":



        """simple docstring"""






        cls._set_token_in_kwargs(_SCREAMING_SNAKE_CASE   )

        UpperCamelCase						,UpperCamelCase       						=      cls.get_config_dict(_SCREAMING_SNAKE_CASE    ,	**_SCREAMING_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(_SCREAMING_SNAKE_CASE    ,	**_SCREAMING_SNAKE_CASE   )

  @classmethod
  def 						A__		(   cls    ,	_SCREAMING_SNAKE_CASE    ,	_SCREAMING_SNAKE_CASE    ,	**_SCREAMING_SNAKE_CASE   )						->   str:



        """simple docstring"""






        UpperCamelCase       						=      {}
        UpperCamelCase       						=      text_config
        UpperCamelCase       						=      vision_config

        return cls.from_dict(_SCREAMING_SNAKE_CASE    ,	**_SCREAMING_SNAKE_CASE   )


  def 						A__		(   self   )						->   Optional[int]:



        """simple docstring"""






        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        a_		(    lowerCamelCase       ):

  @property
  def 						A__		(   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 						A__		(   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 						A__		(   self   )						->   float:



        """simple docstring"""






        return 1e-4

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



        """simple docstring"""






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


  @property
  def 						A__		(   self   )						->   int:



        """simple docstring"""






        return 14








'''simple docstring'''

from typing import TYPE_CHECKING

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


SCREAMING_SNAKE_CASE__											=     {
    'configuration_swiftformer': [
        'SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'SwiftFormerConfig',
        'SwiftFormerOnnxConfig',
    ]
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     SCREAMING_SNAKE_CASE__											=     [
         '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

     SCREAMING_SNAKE_CASE__											=     _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
