

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

__lowerCamelCase										=		{
    "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        _lowercase					(     __UpperCAmelCase     ):
     _lowerCamelCase     =       '''owlvit_text_model'''







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

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







     @classmethod
     def 	lowerCAmelCase__    (      cls ,						UpperCamelCase_ ,						**UpperCamelCase_       ):
      cls._set_token_in_kwargs(UpperCamelCase_       )

      __magic_name__   ,						__magic_name__     =      cls.get_config_dict(UpperCamelCase_ ,						**UpperCamelCase_       )

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







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

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







     @classmethod
     def 	lowerCAmelCase__    (      cls ,						UpperCamelCase_ ,						**UpperCamelCase_       ):
      cls._set_token_in_kwargs(UpperCamelCase_       )

      __magic_name__   ,						__magic_name__     =      cls.get_config_dict(UpperCamelCase_ ,						**UpperCamelCase_       )

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







     def __init__(      self ,						UpperCamelCase_=None ,						UpperCamelCase_=None ,						UpperCamelCase_=512 ,						UpperCamelCase_=2.6_5_9_2 ,						UpperCamelCase_=True ,						**UpperCamelCase_ ,						):
      super().__init__(**UpperCamelCase_       )

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

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

      __magic_name__     =      OwlViTTextConfig(**UpperCamelCase_       )
      __magic_name__     =      OwlViTVisionConfig(**UpperCamelCase_       )

      __magic_name__     =      projection_dim
      __magic_name__     =      logit_scale_init_value
      __magic_name__     =      return_dict
      __magic_name__     =      1.0







     @classmethod
     def 	lowerCAmelCase__    (      cls ,						UpperCamelCase_ ,						**UpperCamelCase_       ):
      cls._set_token_in_kwargs(UpperCamelCase_       )

      __magic_name__   ,						__magic_name__     =      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 	lowerCAmelCase__    (      cls ,						UpperCamelCase_ ,						UpperCamelCase_ ,						**UpperCamelCase_       ):
      __magic_name__     =      {}
      __magic_name__     =      text_config
      __magic_name__     =      vision_config

      return cls.from_dict(UpperCamelCase_ ,						**UpperCamelCase_       )







     def 	lowerCAmelCase__    (      self       ):
      __magic_name__     =      copy.deepcopy(self.__dict__       )
      __magic_name__     =      self.text_config.to_dict()
      __magic_name__     =      self.vision_config.to_dict()
      __magic_name__     =      self.__class__.model_type
      return output


class        _lowercase					(     __UpperCAmelCase     ):







     @property
     def 	lowerCAmelCase__    (      self       ):
      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       ):
      return OrderedDict(
          [
              ('''logits_per_image''', {0: '''batch'''}),
              ('''logits_per_text''', {0: '''batch'''}),
              ('''text_embeds''', {0: '''batch'''}),
              ('''image_embeds''', {0: '''batch'''}),
          ]       )







     @property
     def 	lowerCAmelCase__    (      self       ):
      return 1E-4







     def 	lowerCAmelCase__    (      self ,						UpperCamelCase_ ,						UpperCamelCase_ = -1 ,						UpperCamelCase_ = -1 ,						UpperCamelCase_ = None ,						):
      __magic_name__     =      super().generate_dummy_inputs(
          processor.tokenizer ,						batch_size=UpperCamelCase_ ,						seq_length=UpperCamelCase_ ,						framework=UpperCamelCase_       )
      __magic_name__     =      super().generate_dummy_inputs(
          processor.image_processor ,						batch_size=UpperCamelCase_ ,						framework=UpperCamelCase_       )
      return {**text_input_dict, **image_input_dict}







     @property
     def 	lowerCAmelCase__    (      self       ):
      return 14




"""simple docstring"""






from ...configuration_utils import PretrainedConfig
from ...utils import logging


__lowerCamelCase										=		logging.get_logger(__name__)

__lowerCamelCase										=		{
    "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json",
    "google/fnet-large": "https://huggingface.co/google/fnet-large/resolve/main/config.json"
    # See all FNet models at https://huggingface.co/models?filter=fnet
}
class        _lowercase					(     __UpperCAmelCase     ):
     _lowerCamelCase     =       '''fnet'''







     def __init__(      self ,						UpperCamelCase_=3_2000 ,						UpperCamelCase_=768 ,						UpperCamelCase_=12 ,						UpperCamelCase_=3072 ,						UpperCamelCase_="gelu_new" ,						UpperCamelCase_=0.1 ,						UpperCamelCase_=512 ,						UpperCamelCase_=4 ,						UpperCamelCase_=0.0_2 ,						UpperCamelCase_=1E-1_2 ,						UpperCamelCase_=False ,						UpperCamelCase_=512 ,						UpperCamelCase_=3 ,						UpperCamelCase_=1 ,						UpperCamelCase_=2 ,						**UpperCamelCase_ ,						):
      super().__init__(pad_token_id=UpperCamelCase_ ,						bos_token_id=UpperCamelCase_ ,						eos_token_id=UpperCamelCase_ ,						**UpperCamelCase_       )

      __magic_name__     =      vocab_size
      __magic_name__     =      max_position_embeddings
      __magic_name__     =      hidden_size
      __magic_name__     =      num_hidden_layers
      __magic_name__     =      intermediate_size
      __magic_name__     =      hidden_act
      __magic_name__     =      hidden_dropout_prob
      __magic_name__     =      initializer_range
      __magic_name__     =      type_vocab_size
      __magic_name__     =      layer_norm_eps
      __magic_name__     =      use_tpu_fourier_optimizations
      __magic_name__     =      tpu_short_seq_length

