






'''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 UpperCAmelCase_       (     __A					):




      """simple docstring"""




      UpperCamelCase_             =      '''owlvit_text_model'''






      def __init__(			self      :		Tuple  ,   UpperCAmelCase      :		int=4_9408  ,   UpperCAmelCase      :		int=512  ,   UpperCAmelCase      :		List[Any]=2048  ,   UpperCAmelCase      :		Any=12  ,   UpperCAmelCase      :		Dict=8  ,   UpperCAmelCase      :		Any=16  ,   UpperCAmelCase      :		List[str]="quick_gelu"  ,   UpperCAmelCase      :		Optional[int]=1e-5  ,   UpperCAmelCase      :		Optional[Any]=0.0  ,   UpperCAmelCase      :		Tuple=0.0_2  ,   UpperCAmelCase      :		Any=1.0  ,   UpperCAmelCase      :		List[str]=0  ,   UpperCAmelCase      :		int=4_9406  ,   UpperCAmelCase      :		Optional[Any]=4_9407  ,   **UpperCAmelCase      :		str  ,   )	->	Optional[int]:


       '''simple docstring'''

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

       lowercase       : int						=vocab_size
       lowercase       : Optional[Any]						=hidden_size
       lowercase       : Optional[Any]						=intermediate_size
       lowercase       : Union[str, Any]						=num_hidden_layers
       lowercase       : int						=num_attention_heads
       lowercase       : List[Any]						=max_position_embeddings
       lowercase       : Optional[Any]						=hidden_act
       lowercase       : Optional[int]						=layer_norm_eps
       lowercase       : Tuple						=attention_dropout
       lowercase       : Optional[Any]						=initializer_range
       lowercase       : List[Any]						=initializer_factor






      @classmethod
      def 					A__   (			cls      :		Optional[int]  ,   UpperCAmelCase      :		Union[str, os.PathLike]  ,   **UpperCAmelCase      :		Optional[int]		)	->	"PretrainedConfig":


       '''simple docstring'''

       cls._set_token_in_kwargs(UpperCAmelCase		)

       lowercase	,		lowercase       : Tuple						=cls.get_config_dict(UpperCAmelCase  ,   **UpperCAmelCase		)

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




      """simple docstring"""




      UpperCamelCase_             =      '''owlvit_vision_model'''






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


       '''simple docstring'''

       super().__init__(**UpperCAmelCase		)

       lowercase       : int						=hidden_size
       lowercase       : Dict						=intermediate_size
       lowercase       : Any						=num_hidden_layers
       lowercase       : Any						=num_attention_heads
       lowercase       : Any						=num_channels
       lowercase       : Optional[int]						=image_size
       lowercase       : int						=patch_size
       lowercase       : Union[str, Any]						=hidden_act
       lowercase       : Optional[int]						=layer_norm_eps
       lowercase       : Tuple						=attention_dropout
       lowercase       : List[Any]						=initializer_range
       lowercase       : str						=initializer_factor






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


       '''simple docstring'''

       cls._set_token_in_kwargs(UpperCAmelCase		)

       lowercase	,		lowercase       : int						=cls.get_config_dict(UpperCAmelCase  ,   **UpperCAmelCase		)

       # get the vision config dict if we are loading from OwlViTConfig
       if config_dict.get('''model_type'''		) == "owlvit":
        lowercase       : Optional[int]						=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_       (     __A					):




      """simple docstring"""




      UpperCamelCase_             =      '''owlvit'''
      UpperCamelCase_             =      True






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


       '''simple docstring'''

       super().__init__(**UpperCAmelCase		)

       if text_config is None:
        lowercase       : Union[str, Any]						={}
        logger.info('''text_config is None. Initializing the OwlViTTextConfig with default values.'''		)

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

       lowercase       : List[Any]						=OwlViTTextConfig(**UpperCAmelCase		)
       lowercase       : List[str]						=OwlViTVisionConfig(**UpperCAmelCase		)

       lowercase       : Tuple						=projection_dim
       lowercase       : str						=logit_scale_init_value
       lowercase       : Optional[Any]						=return_dict
       lowercase       : int						=1.0






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


       '''simple docstring'''

       cls._set_token_in_kwargs(UpperCAmelCase		)

       lowercase	,		lowercase       : Optional[int]						=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 					A__   (			cls      :		Union[str, Any]  ,   UpperCAmelCase      :		Dict  ,   UpperCAmelCase      :		Dict  ,   **UpperCAmelCase      :		Any		)	->	Optional[int]:


       '''simple docstring'''

       lowercase       : Optional[int]						={}
       lowercase       : Any						=text_config
       lowercase       : Any						=vision_config

       return cls.from_dict(UpperCAmelCase  ,   **UpperCAmelCase		)






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


       '''simple docstring'''

       lowercase       : List[Any]						=copy.deepcopy(self.__dict__		)
       lowercase       : List[str]						=self.text_config.to_dict()
       lowercase       : Optional[Any]						=self.vision_config.to_dict()
       lowercase       : List[str]						=self.__class__.model_type
       return output





class UpperCAmelCase_       (     __A					):




      """simple docstring"""




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


       '''simple docstring'''

       return 1e-4






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


       '''simple docstring'''

       lowercase       : Union[str, Any]						=super().generate_dummy_inputs(
           processor.tokenizer  ,   batch_size=UpperCAmelCase  ,   seq_length=UpperCAmelCase  ,   framework=UpperCAmelCase		)
       lowercase       : Optional[int]						=super().generate_dummy_inputs(
           processor.image_processor  ,   batch_size=UpperCAmelCase  ,   framework=UpperCAmelCase		)
       return {**text_input_dict, **image_input_dict}






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


       '''simple docstring'''

       return 14











'''simple docstring'''



def 				lowercase_					(     __A			:							int       ,   __A			:							int      )							->   int:



 """simple docstring"""




 return 1 if input_a == input_a else 0


def 				lowercase_					(     )							->   None:



 """simple docstring"""




 assert xnor_gate(0       ,   0      ) == 1
 assert xnor_gate(0       ,   1      ) == 0
 assert xnor_gate(1       ,   0      ) == 0
 assert xnor_gate(1       ,   1      ) == 1


if __name__ == "__main__":
      print(xnor_gate(0, 0))
      print(xnor_gate(0, 1))
      print(xnor_gate(1, 0))
      print(xnor_gate(1, 1))



