"""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					: Optional[Any]        =logging.get_logger(__name__)

__lowerCAmelCase					: List[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 				_A		( lowerCAmelCase			):
      snake_case__    :     List[Any]													=			'owlvit_text_model'

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







            """simple docstring"""



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

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







      @classmethod
      def        A__ (		cls	, __lowerCAmelCase	, **__lowerCAmelCase		):







            """simple docstring"""



            cls._set_token_in_kwargs(__lowerCAmelCase		)

            lowercase							,							lowercase														=			cls.get_config_dict(__lowerCAmelCase	, **__lowerCAmelCase		)

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






class 				_A		( lowerCAmelCase			):
      snake_case__    :     Union[str, Any]													=			'owlvit_vision_model'

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







            """simple docstring"""



            super().__init__(**__lowerCAmelCase		)

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







      @classmethod
      def        A__ (		cls	, __lowerCAmelCase	, **__lowerCAmelCase		):







            """simple docstring"""



            cls._set_token_in_kwargs(__lowerCAmelCase		)

            lowercase							,							lowercase														=			cls.get_config_dict(__lowerCAmelCase	, **__lowerCAmelCase		)

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






class 				_A		( lowerCAmelCase			):
      snake_case__    :     Optional[int]													=			'owlvit'
      snake_case__    :     Optional[Any]													=			True

      def __init__(		self	, __lowerCAmelCase=None	, __lowerCAmelCase=None	, __lowerCAmelCase=512	, __lowerCAmelCase=2.6_5_9_2	, __lowerCAmelCase=True	, **__lowerCAmelCase	, ):







            """simple docstring"""



            super().__init__(**__lowerCAmelCase		)

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

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

            lowercase														=			OwlViTTextConfig(**__lowerCAmelCase		)
            lowercase														=			OwlViTVisionConfig(**__lowerCAmelCase		)

            lowercase														=			projection_dim
            lowercase														=			logit_scale_init_value
            lowercase														=			return_dict
            lowercase														=			1.0

      @classmethod
      def        A__ (		cls	, __lowerCAmelCase	, **__lowerCAmelCase		):







            """simple docstring"""



            cls._set_token_in_kwargs(__lowerCAmelCase		)

            lowercase							,							lowercase														=			cls.get_config_dict(__lowerCAmelCase	, **__lowerCAmelCase		)

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

      @classmethod
      def        A__ (		cls	, __lowerCAmelCase	, __lowerCAmelCase	, **__lowerCAmelCase		):







            """simple docstring"""



            lowercase														=			{}
            lowercase														=			text_config
            lowercase														=			vision_config

            return cls.from_dict(__lowerCAmelCase	, **__lowerCAmelCase		)







      def        A__ (		self		):







            """simple docstring"""



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






class 				_A		( lowerCAmelCase			):

      @property
      def        A__ (		self		):







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







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







            """simple docstring"""



            return 1E-4

      def        A__ (		self	, __lowerCAmelCase	, __lowerCAmelCase = -1	, __lowerCAmelCase = -1	, __lowerCAmelCase = None	, ):







            """simple docstring"""



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







      @property
      def        A__ (		self		):







            """simple docstring"""



            return 14




"""simple docstring"""






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


__lowerCAmelCase					: Any        =logging.get_logger(__name__)

__lowerCAmelCase					: Union[str, Any]        ={
    """facebook/timesformer""": """https://huggingface.co/facebook/timesformer/resolve/main/config.json""",
}





class 				_A		( lowerCAmelCase			):
      snake_case__    :     Optional[Any]													=			'timesformer'

      def __init__(		self	, __lowerCAmelCase=224	, __lowerCAmelCase=16	, __lowerCAmelCase=3	, __lowerCAmelCase=8	, __lowerCAmelCase=768	, __lowerCAmelCase=12	, __lowerCAmelCase=12	, __lowerCAmelCase=3072	, __lowerCAmelCase="gelu"	, __lowerCAmelCase=0.0	, __lowerCAmelCase=0.0	, __lowerCAmelCase=0.0_2	, __lowerCAmelCase=1E-6	, __lowerCAmelCase=True	, __lowerCAmelCase="divided_space_time"	, __lowerCAmelCase=0	, **__lowerCAmelCase	, ):







            """simple docstring"""



            super().__init__(**__lowerCAmelCase		)

            lowercase														=			image_size
            lowercase														=			patch_size
            lowercase														=			num_channels
            lowercase														=			num_frames

            lowercase														=			hidden_size
            lowercase														=			num_hidden_layers
            lowercase														=			num_attention_heads
            lowercase														=			intermediate_size
            lowercase														=			hidden_act
            lowercase														=			hidden_dropout_prob
            lowercase														=			attention_probs_dropout_prob
            lowercase														=			initializer_range
            lowercase														=			layer_norm_eps
            lowercase														=			qkv_bias

            lowercase														=			attention_type
            lowercase														=			drop_path_rate



