






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


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

__UpperCamelCase       :		Tuple							=    {
    """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 	__SCREAMING_SNAKE_CASE(						_lowerCAmelCase						):
							_UpperCAmelCase			     =							'''owlvit_text_model'''
							def __init__(  self:   Tuple							,						UpperCamelCase:   Dict=4_94_08							,						UpperCamelCase:   Any=5_12							,						UpperCamelCase:   Dict=20_48							,						UpperCamelCase:   int=12							,						UpperCamelCase:   List[Any]=8							,						UpperCamelCase:   Tuple=16							,						UpperCamelCase:   Optional[Any]="quick_gelu"							,						UpperCamelCase:   Optional[int]=1e-5							,						UpperCamelCase:   Optional[int]=0.0							,						UpperCamelCase:   Any=0.02							,						UpperCamelCase:   Optional[int]=1.0							,						UpperCamelCase:   Optional[Any]=0							,						UpperCamelCase:   Any=4_94_06							,						UpperCamelCase:   Dict=4_94_07							,						**UpperCamelCase:   Tuple							,						)		->		str:
											super().__init__(pad_token_id=UpperCAmelCase_							,						bos_token_id=UpperCAmelCase_							,						eos_token_id=UpperCAmelCase_							,						**UpperCAmelCase_    )

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


							@classmethod
							def lowerCAmelCase_			(  cls:   str							,						UpperCamelCase:   Union[str, os.PathLike]							,						**UpperCamelCase:   Union[str, Any]    )		->		"PretrainedConfig":
											cls._set_token_in_kwargs(UpperCAmelCase_    )

											snake_case__				,    snake_case__						=  cls.get_config_dict(UpperCAmelCase_							,						**UpperCAmelCase_    )

											# get the text config dict if we are loading from OwlViTConfig
											if config_dict.get('model_type'    ) == "owlvit":
															snake_case__						=  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 	__SCREAMING_SNAKE_CASE(						_lowerCAmelCase						):
							_UpperCAmelCase			     =							'''owlvit_vision_model'''
							def __init__(  self:   Any							,						UpperCamelCase:   Any=7_68							,						UpperCamelCase:   Any=30_72							,						UpperCamelCase:   Optional[int]=12							,						UpperCamelCase:   Any=12							,						UpperCamelCase:   List[Any]=3							,						UpperCamelCase:   str=7_68							,						UpperCamelCase:   List[str]=32							,						UpperCamelCase:   int="quick_gelu"							,						UpperCamelCase:   int=1e-5							,						UpperCamelCase:   Optional[Any]=0.0							,						UpperCamelCase:   Any=0.02							,						UpperCamelCase:   str=1.0							,						**UpperCamelCase:   int							,						)		->		str:
											super().__init__(**UpperCAmelCase_    )

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


							@classmethod
							def lowerCAmelCase_			(  cls:   List[str]							,						UpperCamelCase:   Union[str, os.PathLike]							,						**UpperCamelCase:   Tuple    )		->		"PretrainedConfig":
											cls._set_token_in_kwargs(UpperCAmelCase_    )

											snake_case__				,    snake_case__						=  cls.get_config_dict(UpperCAmelCase_							,						**UpperCAmelCase_    )

											# get the vision config dict if we are loading from OwlViTConfig
											if config_dict.get('model_type'    ) == "owlvit":
															snake_case__						=  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 	__SCREAMING_SNAKE_CASE(						_lowerCAmelCase						):
							_UpperCAmelCase			     =							'''owlvit'''
							_UpperCAmelCase			     =							True
							def __init__(  self:   List[str]							,						UpperCamelCase:   List[str]=None							,						UpperCamelCase:   Dict=None							,						UpperCamelCase:   Dict=5_12							,						UpperCamelCase:   int=2.6_592							,						UpperCamelCase:   Any=True							,						**UpperCamelCase:   Dict							,						)		->		Optional[Any]:
											super().__init__(**UpperCAmelCase_    )

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

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

											snake_case__						=  OwlViTTextConfig(**UpperCAmelCase_    )
											snake_case__						=  OwlViTVisionConfig(**UpperCAmelCase_    )

											snake_case__						=  projection_dim
											snake_case__						=  logit_scale_init_value
											snake_case__						=  return_dict
											snake_case__						=  1.0
							@classmethod
							def lowerCAmelCase_			(  cls:   Dict							,						UpperCamelCase:   Union[str, os.PathLike]							,						**UpperCamelCase:   Any    )		->		"PretrainedConfig":
											cls._set_token_in_kwargs(UpperCAmelCase_    )

											snake_case__				,    snake_case__						=  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:   Any							,						UpperCamelCase:   Dict							,						UpperCamelCase:   Dict							,						**UpperCamelCase:   str    )		->		Tuple:
											snake_case__						=  {}
											snake_case__						=  text_config
											snake_case__						=  vision_config

											return cls.from_dict(UpperCAmelCase_							,						**UpperCAmelCase_    )


							def lowerCAmelCase_			(  self:   Tuple    )		->		Any:
											snake_case__						=  copy.deepcopy(self.__dict__    )
											snake_case__						=  self.text_config.to_dict()
											snake_case__						=  self.vision_config.to_dict()
											snake_case__						=  self.__class__.model_type
											return output


class 	__SCREAMING_SNAKE_CASE(						_lowerCAmelCase						):
							@property
							def lowerCAmelCase_			(  self:   List[Any]    )		->		Mapping[str, Mapping[int, str]]:
											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:   Optional[int]    )		->		Mapping[str, Mapping[int, str]]:
											return OrderedDict(
											    [
											        ('logits_per_image', {0: 'batch'}),
											        ('logits_per_text', {0: 'batch'}),
											        ('text_embeds', {0: 'batch'}),
											        ('image_embeds', {0: 'batch'}),
											    ]    )
							@property
							def lowerCAmelCase_			(  self:   Dict    )		->		float:
											return 1e-4
							def lowerCAmelCase_			(  self:   Optional[Any]							,						UpperCamelCase:   "ProcessorMixin"							,						UpperCamelCase:   int = -1							,						UpperCamelCase:   int = -1							,						UpperCamelCase:   Optional["TensorType"] = None							,						)		->		Mapping[str, Any]:
											snake_case__						=  super().generate_dummy_inputs(
											    processor.tokenizer							,						batch_size=UpperCAmelCase_							,						seq_length=UpperCAmelCase_							,						framework=UpperCAmelCase_    )
											snake_case__						=  super().generate_dummy_inputs(
											    processor.image_processor							,						batch_size=UpperCAmelCase_							,						framework=UpperCAmelCase_    )
											return {**text_input_dict, **image_input_dict}


							@property
							def lowerCAmelCase_			(  self:   Tuple    )		->		int:
											return 14






"""simple docstring"""


from collections import OrderedDict
from typing import TYPE_CHECKING, Any, Mapping, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


if TYPE_CHECKING:
      from ... import FeatureExtractionMixin, PreTrainedTokenizerBase, TensorType


SCREAMING_SNAKE_CASE			  =  logging.get_logger(__name__)

SCREAMING_SNAKE_CASE			  =  {
    """microsoft/deberta-v2-xlarge""": """https://huggingface.co/microsoft/deberta-v2-xlarge/resolve/main/config.json""",
    """microsoft/deberta-v2-xxlarge""": """https://huggingface.co/microsoft/deberta-v2-xxlarge/resolve/main/config.json""",
    """microsoft/deberta-v2-xlarge-mnli""": (
        """https://huggingface.co/microsoft/deberta-v2-xlarge-mnli/resolve/main/config.json"""
    ),
    """microsoft/deberta-v2-xxlarge-mnli""": (
        """https://huggingface.co/microsoft/deberta-v2-xxlarge-mnli/resolve/main/config.json"""
    ),
}



class 	__a	(   _lowerCAmelCase						):
       UpperCamelCase_		:       Any				=      '''deberta-v2'''






       def __init__(	self			:				Dict							,   UpperCAmelCase_			:				Optional[int]=128_100							,   UpperCAmelCase_			:				List[str]=1_536							,   UpperCAmelCase_			:				List[str]=24							,   UpperCAmelCase_			:				int=24							,   UpperCAmelCase_			:				int=6_144							,   UpperCAmelCase_			:				Optional[Any]="gelu"							,   UpperCAmelCase_			:				Tuple=0.1							,   UpperCAmelCase_			:				int=0.1							,   UpperCAmelCase_			:				Optional[int]=512							,   UpperCAmelCase_			:				Optional[int]=0							,   UpperCAmelCase_			:				Dict=0.02							,   UpperCAmelCase_			:				Optional[Any]=1e-7							,   UpperCAmelCase_			:				str=False							,   UpperCAmelCase_			:				Tuple=-1							,   UpperCAmelCase_			:				Optional[int]=0							,   UpperCAmelCase_			:				List[str]=True							,   UpperCAmelCase_			:				Any=None							,   UpperCAmelCase_			:				Optional[Any]=0							,   UpperCAmelCase_			:				Optional[Any]="gelu"							,   **UpperCAmelCase_			:				Optional[int]							,   )->	int:







              """simple docstring"""
              super().__init__(**UpperCAmelCase_      )

              UpperCamelCase       			=		hidden_size
              UpperCamelCase       			=		num_hidden_layers
              UpperCamelCase       			=		num_attention_heads
              UpperCamelCase       			=		intermediate_size
              UpperCamelCase       			=		hidden_act
              UpperCamelCase       			=		hidden_dropout_prob
              UpperCamelCase       			=		attention_probs_dropout_prob
              UpperCamelCase       			=		max_position_embeddings
              UpperCamelCase       			=		type_vocab_size
              UpperCamelCase       			=		initializer_range
              UpperCamelCase       			=		relative_attention
              UpperCamelCase       			=		max_relative_positions
              UpperCamelCase       			=		pad_token_id
              UpperCamelCase       			=		position_biased_input

              # Backwards compatibility
              if type(UpperCAmelCase_      ) == str:
                     UpperCamelCase       			=		[x.strip() for x in pos_att_type.lower().split("|"      )]

              UpperCamelCase       			=		pos_att_type
              UpperCamelCase       			=		vocab_size
              UpperCamelCase       			=		layer_norm_eps

              UpperCamelCase       			=		kwargs.get("pooler_hidden_size"							,   UpperCAmelCase_      )
              UpperCamelCase       			=		pooler_dropout
              UpperCamelCase       			=		pooler_hidden_act





class 	__a	(   _lowerCAmelCase						):






       @property
       def 						_SCREAMING_SNAKE_CASE							(	self			:				Optional[Any]      )->	Mapping[str, Mapping[int, str]]:







              """simple docstring"""
              if self.task == "multiple-choice":
                     UpperCamelCase       			=		{0: "batch", 1: "choice", 2: "sequence"}
              else:
                     UpperCamelCase       			=		{0: "batch", 1: "sequence"}
              if self._config.type_vocab_size > 0:
                     return OrderedDict(
                         [("input_ids", dynamic_axis), ("attention_mask", dynamic_axis), ("token_type_ids", dynamic_axis)]      )
              else:
                     return OrderedDict([("input_ids", dynamic_axis), ("attention_mask", dynamic_axis)]      )






       @property
       def 						_SCREAMING_SNAKE_CASE							(	self			:				Union[str, Any]      )->	int:







              """simple docstring"""
              return 12






       def 						_SCREAMING_SNAKE_CASE							(	self			:				List[str]							,   UpperCAmelCase_			:				Union["PreTrainedTokenizerBase", "FeatureExtractionMixin"]							,   UpperCAmelCase_			:				int = -1							,   UpperCAmelCase_			:				int = -1							,   UpperCAmelCase_			:				int = -1							,   UpperCAmelCase_			:				bool = False							,   UpperCAmelCase_			:				Optional["TensorType"] = None							,   UpperCAmelCase_			:				int = 3							,   UpperCAmelCase_			:				int = 40							,   UpperCAmelCase_			:				int = 40							,   UpperCAmelCase_			:				"PreTrainedTokenizerBase" = None							,   )->	Mapping[str, Any]:







              """simple docstring"""
              UpperCamelCase       			=		super().generate_dummy_inputs(preprocessor=UpperCAmelCase_							,   framework=UpperCAmelCase_      )
              if self._config.type_vocab_size == 0 and "token_type_ids" in dummy_inputs:
                     del dummy_inputs["token_type_ids"]
              return dummy_inputs





