



"""simple docstring"""





import inspect
import unittest

from huggingface_hub import hf_hub_download

from transformers import ConvNextConfig, UperNetConfig
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
  import torch

  from transformers import UperNetForSemanticSegmentation
  from transformers.models.upernet.modeling_upernet import UPERNET_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
  from PIL import Image

  from transformers import AutoImageProcessor
class    lowercase__     :







       '''simple docstring'''


       def __init__(							self    :						Dict	,       _UpperCAmelCase    :						Optional[int]	,       _UpperCAmelCase    :						int=13	,       _UpperCAmelCase    :						Optional[int]=32	,       _UpperCAmelCase    :						str=3	,       _UpperCAmelCase    :						Optional[int]=4	,       _UpperCAmelCase    :						int=[10, 20, 30, 40]	,       _UpperCAmelCase    :						List[str]=[2, 2, 3, 2]	,       _UpperCAmelCase    :						Union[str, Any]=True	,       _UpperCAmelCase    :						List[str]=True	,       _UpperCAmelCase    :						str=37	,       _UpperCAmelCase    :						List[Any]="gelu"	,       _UpperCAmelCase    :						int=10	,       _UpperCAmelCase    :						List[Any]=0.02	,       _UpperCAmelCase    :						Optional[Any]=["stage2", "stage3", "stage4"]	,       _UpperCAmelCase    :						List[Any]=3	,       _UpperCAmelCase    :						Union[str, Any]=None	,       )				->		Optional[Any]:


             '''simple docstring'''




             UpperCAmelCase_    				=							parent
             UpperCAmelCase_    				=							batch_size
             UpperCAmelCase_    				=							image_size
             UpperCAmelCase_    				=							num_channels
             UpperCAmelCase_    				=							num_stages
             UpperCAmelCase_    				=							hidden_sizes
             UpperCAmelCase_    				=							depths
             UpperCAmelCase_    				=							is_training
             UpperCAmelCase_    				=							use_labels
             UpperCAmelCase_    				=							intermediate_size
             UpperCAmelCase_    				=							hidden_act
             UpperCAmelCase_    				=							type_sequence_label_size
             UpperCAmelCase_    				=							initializer_range
             UpperCAmelCase_    				=							out_features
             UpperCAmelCase_    				=							num_labels
             UpperCAmelCase_    				=							scope
             UpperCAmelCase_    				=							num_stages



       def   lowercase__       (							self    :						int					)				->		List[str]:


             '''simple docstring'''




             UpperCAmelCase_    				=							floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]					)

             UpperCAmelCase_    				=							None
             if self.use_labels:
                   UpperCAmelCase_    				=							ids_tensor([self.batch_size]	,       self.type_sequence_label_size					)

             UpperCAmelCase_    				=							self.get_config()

             return config, pixel_values, labels



       def   lowercase__       (							self    :						Dict					)				->		Dict:


             '''simple docstring'''




             return ConvNextConfig(
                 num_channels=self.num_channels	,       num_stages=self.num_stages	,       hidden_sizes=self.hidden_sizes	,       depths=self.depths	,       is_training=self.is_training	,       intermediate_size=self.intermediate_size	,       hidden_act=self.hidden_act	,       out_features=self.out_features	,       )



       def   lowercase__       (							self    :						List[Any]					)				->		Union[str, Any]:


             '''simple docstring'''




             return UperNetConfig(
                 backbone_config=self.get_backbone_config()	,       hidden_size=512	,       pool_scales=[1, 2, 3, 6]	,       use_auxiliary_head=_UpperCAmelCase	,       auxiliary_loss_weight=0.4	,       auxiliary_in_channels=40	,       auxiliary_channels=256	,       auxiliary_num_convs=1	,       auxiliary_concat_input=_UpperCAmelCase	,       loss_ignore_index=255	,       num_labels=self.num_labels	,       )



       def   lowercase__       (							self    :						Optional[Any]	,       _UpperCAmelCase    :						Dict	,       _UpperCAmelCase    :						Optional[int]	,       _UpperCAmelCase    :						Dict					)				->		Optional[Any]:


             '''simple docstring'''




             UpperCAmelCase_    				=							UperNetForSemanticSegmentation(config=_UpperCAmelCase					)
             model.to(_UpperCAmelCase					)
             model.eval()
             UpperCAmelCase_    				=							model(_UpperCAmelCase					)
             self.parent.assertEqual(
                 result.logits.shape	,       (self.batch_size, self.num_labels, self.image_size, self.image_size)					)







       def   lowercase__       (							self    :						int					)				->		Optional[Any]:


             '''simple docstring'''




             UpperCAmelCase_    				=							self.prepare_config_and_inputs()
             (
                 (
                 UpperCAmelCase_
             )				,					(
                 UpperCAmelCase_
             )				,					(
                 UpperCAmelCase_
             )				,					
             )    				=							config_and_inputs
             UpperCAmelCase_    				=							{"pixel_values": pixel_values}
             return config, inputs_dict



@require_torch
class    lowercase__     (					SCREAMING_SNAKE_CASE       ,      SCREAMING_SNAKE_CASE       ,      unittest.TestCase   ):







       '''simple docstring'''


       UpperCamelCase		=  (UperNetForSemanticSegmentation,) if is_torch_available() else ()
       UpperCamelCase		=  {'''image-segmentation''': UperNetForSemanticSegmentation} if is_torch_available() else {}
       UpperCamelCase		=  False
       UpperCamelCase		=  False
       UpperCamelCase		=  False
       UpperCamelCase		=  False
       UpperCamelCase		=  False
       UpperCamelCase		=  False



       def   lowercase__       (							self    :						List[str]					)				->		Optional[int]:


             '''simple docstring'''




             UpperCAmelCase_    				=							UperNetModelTester(self					)
             UpperCAmelCase_    				=							ConfigTester(self	,       config_class=_UpperCAmelCase	,       has_text_modality=_UpperCAmelCase	,       hidden_size=37					)



       def   lowercase__       (							self    :						Optional[int]					)				->		Any:


             '''simple docstring'''




             self.create_and_test_config_common_properties()
             self.config_tester.create_and_test_config_to_json_string()
             self.config_tester.create_and_test_config_to_json_file()
             self.config_tester.create_and_test_config_from_and_save_pretrained()
             self.config_tester.create_and_test_config_with_num_labels()
             self.config_tester.check_config_can_be_init_without_params()
             self.config_tester.check_config_arguments_init()



       def   lowercase__       (							self    :						Optional[int]					)				->		Optional[Any]:


             '''simple docstring'''




             return



       def   lowercase__       (							self    :						Optional[int]					)				->		List[Any]:


             '''simple docstring'''




             UpperCAmelCase_				,					UpperCAmelCase_    				=							self.model_tester.prepare_config_and_inputs_for_common()

             for model_class in self.all_model_classes:
                   UpperCAmelCase_    				=							model_class(_UpperCAmelCase					)
                   UpperCAmelCase_    				=							inspect.signature(model.forward					)
                   # signature.parameters is an OrderedDict => so arg_names order is deterministic
                   UpperCAmelCase_    				=							[*signature.parameters.keys()]

                   UpperCAmelCase_    				=							["pixel_values"]
                   self.assertListEqual(arg_names[:1]	,       _UpperCAmelCase					)



       def   lowercase__       (							self    :						List[str]					)				->		str:


             '''simple docstring'''




             UpperCAmelCase_    				=							self.model_tester.prepare_config_and_inputs()
             self.model_tester.create_and_check_for_semantic_segmentation(*_UpperCAmelCase					)



       @unittest.skip(reason="UperNet does not use inputs_embeds"					)
       def   lowercase__       (							self    :						List[str]					)				->		Optional[int]:


             '''simple docstring'''




             pass



       @unittest.skip(reason="UperNet does not support input and output embeddings"					)
       def   lowercase__       (							self    :						List[str]					)				->		Any:


             '''simple docstring'''




             pass



       @unittest.skip(reason="UperNet does not have a base model"					)
       def   lowercase__       (							self    :						str					)				->		Tuple:


             '''simple docstring'''




             pass



       @unittest.skip(reason="UperNet does not have a base model"					)
       def   lowercase__       (							self    :						Optional[Any]					)				->		str:


             '''simple docstring'''




             pass



       @require_torch_multi_gpu
       @unittest.skip(reason="UperNet has some layers using `add_module` which doesn't work well with `nn.DataParallel`"					)
       def   lowercase__       (							self    :						List[Any]					)				->		Dict:


             '''simple docstring'''




             pass



       @unittest.skip("Will be fixed soon by reducing the size of the model used for common tests."					)
       def   lowercase__       (							self    :						str					)				->		int:


             '''simple docstring'''




             pass



       def   lowercase__       (							self    :						int					)				->		Tuple:


             '''simple docstring'''




             def check_hidden_states_output(_UpperCAmelCase    :						Any	,       _UpperCAmelCase    :						Optional[Any]	,       _UpperCAmelCase    :						str					):
                   UpperCAmelCase_    				=							model_class(_UpperCAmelCase					)
                   model.to(_UpperCAmelCase					)
                   model.eval()

                   with torch.no_grad():
                         UpperCAmelCase_    				=							model(**self._prepare_for_class(_UpperCAmelCase	,       _UpperCAmelCase					)					)

                   UpperCAmelCase_    				=							outputs.encoder_hidden_states if config.is_encoder_decoder else outputs.hidden_states

                   UpperCAmelCase_    				=							self.model_tester.num_stages
                   self.assertEqual(len(_UpperCAmelCase					)	,       expected_num_stages + 1					)

                   # ConvNext's feature maps are of shape (batch_size, num_channels, height, width)
                   self.assertListEqual(
                       list(hidden_states[0].shape[-2:]					)	,       [self.model_tester.image_size // 4, self.model_tester.image_size // 4]	,       )

             UpperCAmelCase_				,					UpperCAmelCase_    				=							self.model_tester.prepare_config_and_inputs_for_common()

             for model_class in self.all_model_classes:
                   UpperCAmelCase_    				=							True
                   check_hidden_states_output(_UpperCAmelCase	,       _UpperCAmelCase	,       _UpperCAmelCase					)

                   # check that output_hidden_states also work using config
                   del inputs_dict["output_hidden_states"]
                   UpperCAmelCase_    				=							True

                   check_hidden_states_output(_UpperCAmelCase	,       _UpperCAmelCase	,       _UpperCAmelCase					)



       def   lowercase__       (							self    :						Union[str, Any]					)				->		Optional[int]:


             '''simple docstring'''




             UpperCAmelCase_				,					UpperCAmelCase_    				=							self.model_tester.prepare_config_and_inputs_for_common()

             UpperCAmelCase_    				=							_config_zero_init(_UpperCAmelCase					)
             UpperCAmelCase_    				=							_config_zero_init(configs_no_init.backbone_config					)
             for model_class in self.all_model_classes:
                   UpperCAmelCase_    				=							model_class(config=_UpperCAmelCase					)
                   for name, param in model.named_parameters():
                         if param.requires_grad:
                               self.assertIn(
                                   ((param.data.mean() * 1e9).round() / 1e9).item()	,       [0.0, 1.0]	,       msg=F"""Parameter {name} of model {model_class} seems not properly initialized"""	,       )



       @unittest.skip(reason="UperNet does not have tied weights"					)
       def   lowercase__       (							self    :						int					)				->		Union[str, Any]:


             '''simple docstring'''




             pass







       @slow
       def   lowercase__       (							self    :						Union[str, Any]					)				->		Dict:


             '''simple docstring'''




             for model_name in UPERNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
                   UpperCAmelCase_    				=							UperNetForSemanticSegmentation.from_pretrained(_UpperCAmelCase					)
                   self.assertIsNotNone(_UpperCAmelCase					)



def      a__			(   ):
      UpperCAmelCase_    				=							hf_hub_download(
          repo_id="hf-internal-testing/fixtures_ade20k"			,    repo_type="dataset"			,    filename="ADE_val_00000001.jpg"   )
      UpperCAmelCase_    				=							Image.open(lowerCAmelCase__   ).convert("RGB"   )
      return image


@require_torch
@require_vision
@slow
class    lowercase__     (					unittest.TestCase   ):







       '''simple docstring'''


       def   lowercase__       (							self    :						Optional[int]					)				->		Dict:


             '''simple docstring'''




             UpperCAmelCase_    				=							AutoImageProcessor.from_pretrained("openmmlab/upernet-swin-tiny"					)
             UpperCAmelCase_    				=							UperNetForSemanticSegmentation.from_pretrained("openmmlab/upernet-swin-tiny"					).to(_UpperCAmelCase					)

             UpperCAmelCase_    				=							prepare_img()
             UpperCAmelCase_    				=							processor(images=_UpperCAmelCase	,       return_tensors="pt"					).to(_UpperCAmelCase					)

             with torch.no_grad():
                   UpperCAmelCase_    				=							model(**_UpperCAmelCase					)

             UpperCAmelCase_    				=							torch.Size((1, model.config.num_labels, 512, 512)					)
             self.assertEqual(outputs.logits.shape	,       _UpperCAmelCase					)

             UpperCAmelCase_    				=							torch.tensor(
                 [[-7.5958, -7.5958, -7.4302], [-7.5958, -7.5958, -7.4302], [-7.4797, -7.4797, -7.3068]]					).to(_UpperCAmelCase					)
             self.assertTrue(torch.allclose(outputs.logits[0, 0, :3, :3]	,       _UpperCAmelCase	,       atol=1e-4					)					)







       def   lowercase__       (							self    :						Any					)				->		List[str]:


             '''simple docstring'''




             UpperCAmelCase_    				=							AutoImageProcessor.from_pretrained("openmmlab/upernet-convnext-tiny"					)
             UpperCAmelCase_    				=							UperNetForSemanticSegmentation.from_pretrained("openmmlab/upernet-convnext-tiny"					).to(_UpperCAmelCase					)

             UpperCAmelCase_    				=							prepare_img()
             UpperCAmelCase_    				=							processor(images=_UpperCAmelCase	,       return_tensors="pt"					).to(_UpperCAmelCase					)

             with torch.no_grad():
                   UpperCAmelCase_    				=							model(**_UpperCAmelCase					)

             UpperCAmelCase_    				=							torch.Size((1, model.config.num_labels, 512, 512)					)
             self.assertEqual(outputs.logits.shape	,       _UpperCAmelCase					)

             UpperCAmelCase_    				=							torch.tensor(
                 [[-8.8110, -8.8110, -8.6521], [-8.8110, -8.8110, -8.6521], [-8.7746, -8.7746, -8.6130]]					).to(_UpperCAmelCase					)
             self.assertTrue(torch.allclose(outputs.logits[0, 0, :3, :3]	,       _UpperCAmelCase	,       atol=1e-4					)					)









"""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__     (					SCREAMING_SNAKE_CASE   ):







       '''simple docstring'''


       UpperCamelCase		=  '''owlvit_text_model'''



       def __init__(							self    :						List[Any]	,       _UpperCAmelCase    :						str=49408	,       _UpperCAmelCase    :						str=512	,       _UpperCAmelCase    :						Optional[Any]=2048	,       _UpperCAmelCase    :						Optional[int]=12	,       _UpperCAmelCase    :						Tuple=8	,       _UpperCAmelCase    :						List[str]=16	,       _UpperCAmelCase    :						List[str]="quick_gelu"	,       _UpperCAmelCase    :						Dict=1e-5	,       _UpperCAmelCase    :						Union[str, Any]=0.0	,       _UpperCAmelCase    :						List[Any]=0.02	,       _UpperCAmelCase    :						Optional[int]=1.0	,       _UpperCAmelCase    :						Dict=0	,       _UpperCAmelCase    :						Dict=49406	,       _UpperCAmelCase    :						Union[str, Any]=49407	,       **_UpperCAmelCase    :						List[str]	,       )				->		List[str]:


             '''simple docstring'''




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

             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   lowercase__       (							cls    :						int	,       _UpperCAmelCase    :						Union[str, os.PathLike]	,       **_UpperCAmelCase    :						List[str]					)				->		"PretrainedConfig":


             '''simple docstring'''




             cls._set_token_in_kwargs(_UpperCAmelCase					)

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

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



class    lowercase__     (					SCREAMING_SNAKE_CASE   ):







       '''simple docstring'''


       UpperCamelCase		=  '''owlvit_vision_model'''



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


             '''simple docstring'''




             super().__init__(**_UpperCAmelCase					)

             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   lowercase__       (							cls    :						Any	,       _UpperCAmelCase    :						Union[str, os.PathLike]	,       **_UpperCAmelCase    :						Union[str, Any]					)				->		"PretrainedConfig":


             '''simple docstring'''




             cls._set_token_in_kwargs(_UpperCAmelCase					)

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

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



class    lowercase__     (					SCREAMING_SNAKE_CASE   ):







       '''simple docstring'''


       UpperCamelCase		=  '''owlvit'''
       UpperCamelCase		=  True



       def __init__(							self    :						Tuple	,       _UpperCAmelCase    :						Any=None	,       _UpperCAmelCase    :						Dict=None	,       _UpperCAmelCase    :						Tuple=512	,       _UpperCAmelCase    :						Any=2.6592	,       _UpperCAmelCase    :						Union[str, Any]=True	,       **_UpperCAmelCase    :						Union[str, Any]	,       )				->		Tuple:


             '''simple docstring'''




             super().__init__(**_UpperCAmelCase					)

             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(**_UpperCAmelCase					)
             UpperCAmelCase_    				=							OwlViTVisionConfig(**_UpperCAmelCase					)

             UpperCAmelCase_    				=							projection_dim
             UpperCAmelCase_    				=							logit_scale_init_value
             UpperCAmelCase_    				=							return_dict
             UpperCAmelCase_    				=							1.0



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


             '''simple docstring'''




             cls._set_token_in_kwargs(_UpperCAmelCase					)

             UpperCAmelCase_				,					UpperCAmelCase_    				=							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   lowercase__       (							cls    :						List[str]	,       _UpperCAmelCase    :						Dict	,       _UpperCAmelCase    :						Dict	,       **_UpperCAmelCase    :						Any					)				->		Union[str, Any]:


             '''simple docstring'''




             UpperCAmelCase_    				=							{}
             UpperCAmelCase_    				=							text_config
             UpperCAmelCase_    				=							vision_config

             return cls.from_dict(_UpperCAmelCase	,       **_UpperCAmelCase					)







       def   lowercase__       (							self    :						str					)				->		List[str]:


             '''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    lowercase__     (					SCREAMING_SNAKE_CASE   ):







       '''simple docstring'''


       @property
       def   lowercase__       (							self    :						Union[str, Any]					)				->		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   lowercase__       (							self    :						Tuple					)				->		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   lowercase__       (							self    :						Any					)				->		float:


             '''simple docstring'''




             return 1e-4



       def   lowercase__       (							self    :						List[str]	,       _UpperCAmelCase    :						"ProcessorMixin"	,       _UpperCAmelCase    :						int = -1	,       _UpperCAmelCase    :						int = -1	,       _UpperCAmelCase    :						Optional["TensorType"] = None	,       )				->		Mapping[str, Any]:


             '''simple docstring'''




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







       @property
       def   lowercase__       (							self    :						Dict					)				->		int:


             '''simple docstring'''




             return 14




