


'''simple docstring'''


import inspect
import unittest

import numpy as np

from tests.test_modeling_common import floats_tensor
from transformers import MaskaFormerConfig, is_torch_available, is_vision_available
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
     import torch

     from transformers import MaskaFormerForUniversalSegmentation, MaskaFormerModel

     if is_vision_available():
          from transformers import MaskaFormerImageProcessor

if is_vision_available():
     from PIL import Image



class 	__lowerCAmelCase		:


  '''simple docstring'''







  def __init__(							self :       Dict	,_a :       str	,_a :       Optional[Any]=2	,_a :       Union[str, Any]=True	,_a :       Optional[int]=False	,_a :       List[str]=10	,_a :       Dict=3	,_a :       Optional[Any]=32 * 8	,_a :       Dict=32 * 8	,_a :       str=4	,_a :       Dict=64	,):

        '''simple docstring'''




        A_						:  List[Any]          =				parent
        A_						:  Optional[Any]          =				batch_size
        A_						:  Dict          =				is_training
        A_						:  str          =				use_auxiliary_loss
        A_						:  Optional[int]          =				num_queries
        A_						:  Union[str, Any]          =				num_channels
        A_						:  Optional[Any]          =				min_size
        A_						:  Union[str, Any]          =				max_size
        A_						:  int          =				num_labels
        A_						:  Dict          =				hidden_dim
        A_						:  Optional[int]          =				hidden_dim






  def        _a							(							self :       Optional[Any] ):

        '''simple docstring'''




        A_						:  Optional[int]          =				floats_tensor([self.batch_size, self.num_channels, self.min_size, self.max_size] ).to(
            _a )

        A_						:  List[Any]          =				torch.ones([self.batch_size, self.min_size, self.max_size]	,device=_a )

        A_						:  Any          =				(
            torch.rand([self.batch_size, self.num_labels, self.min_size, self.max_size]	,device=_a ) > 0.5
        ).float()
        A_						:  List[str]          =				(torch.rand((self.batch_size, self.num_labels)	,device=_a ) > 0.5).long()

        A_						:  int          =				self.get_config()
        return config, pixel_values, pixel_mask, mask_labels, class_labels






  def        _a							(							self :       Any ):

        '''simple docstring'''




        A_						:  List[str]          =				MaskaFormerConfig(
            hidden_size=self.hidden_dim	,)
        A_						:  Optional[Any]          =				self.num_queries
        A_						:  Any          =				self.num_labels

        A_						:  Dict          =				[1, 1, 1, 1]
        A_						:  str          =				self.num_channels

        A_						:  List[Any]          =				64
        A_						:  Optional[Any]          =				128
        A_						:  List[str]          =				self.hidden_dim
        A_						:  str          =				self.hidden_dim
        A_						:  List[Any]          =				self.hidden_dim
        return config






  def        _a							(							self :       List[Any] ):

        '''simple docstring'''




        A_   ,					A_   ,					A_   ,					A_   ,					A_						:  Union[str, Any]          =				self.prepare_config_and_inputs()
        A_						:  int          =				{"""pixel_values""": pixel_values, """pixel_mask""": pixel_mask}
        return config, inputs_dict






  def        _a							(							self :       Tuple	,_a :       Tuple	,_a :       str ):

        '''simple docstring'''




        A_						:  int          =				output.encoder_hidden_states
        A_						:  Tuple          =				output.pixel_decoder_hidden_states
        A_						:  str          =				output.transformer_decoder_hidden_states

        self.parent.assertTrue(len(_a )	,len(config.backbone_config.depths ) )
        self.parent.assertTrue(len(_a )	,len(config.backbone_config.depths ) )
        self.parent.assertTrue(len(_a )	,config.decoder_layers )






  def        _a							(							self :       Tuple	,_a :       List[str]	,_a :       List[Any]	,_a :       str	,_a :       Union[str, Any]=False ):

        '''simple docstring'''




        with torch.no_grad():
              A_						:  Optional[Any]          =				MaskaFormerModel(config=_a )
              model.to(_a )
              model.eval()

              A_						:  Dict          =				model(pixel_values=_a	,pixel_mask=_a )
              A_						:  str          =				model(_a	,output_hidden_states=_a )

        self.parent.assertEqual(
            output.transformer_decoder_last_hidden_state.shape	,(self.batch_size, self.num_queries, self.hidden_dim)	,)
        # let's ensure the other two hidden state exists
        self.parent.assertTrue(output.pixel_decoder_last_hidden_state is not None )
        self.parent.assertTrue(output.encoder_last_hidden_state is not None )

        if output_hidden_states:
              self.check_output_hidden_state(_a	,_a )






  def        _a							(							self :       Optional[int]	,_a :       Any	,_a :       Union[str, Any]	,_a :       str	,_a :       Tuple	,_a :       Any ):

        '''simple docstring'''




        A_						:  Dict          =				MaskaFormerForUniversalSegmentation(config=_a )
        model.to(_a )
        model.eval()

        def comm_check_on_output(_a :       Union[str, Any] ):
              # let's still check that all the required stuff is there
              self.parent.assertTrue(result.transformer_decoder_last_hidden_state is not None )
              self.parent.assertTrue(result.pixel_decoder_last_hidden_state is not None )
              self.parent.assertTrue(result.encoder_last_hidden_state is not None )
              # okay, now we need to check the logits shape
              # due to the encoder compression, masks have a //4 spatial size
              self.parent.assertEqual(
                  result.masks_queries_logits.shape	,(self.batch_size, self.num_queries, self.min_size // 4, self.max_size // 4)	,)
              # + 1 for null class
              self.parent.assertEqual(
                  result.class_queries_logits.shape	,(self.batch_size, self.num_queries, self.num_labels + 1) )

        with torch.no_grad():
              A_						:  Union[str, Any]          =				model(pixel_values=_a	,pixel_mask=_a )
              A_						:  Dict          =				model(_a )

              comm_check_on_output(_a )

              A_						:  Union[str, Any]          =				model(
                  pixel_values=_a	,pixel_mask=_a	,mask_labels=_a	,class_labels=_a )

        comm_check_on_output(_a )

        self.parent.assertTrue(result.loss is not None )
        self.parent.assertEqual(result.loss.shape	,torch.Size([1] ) )







@require_torch
class 	__lowerCAmelCase		(							__SCREAMING_SNAKE_CASE  , __SCREAMING_SNAKE_CASE  , unittest.TestCase    ):


  '''simple docstring'''







  a_  					=							(MaskaFormerModel, MaskaFormerForUniversalSegmentation) if is_torch_available() else ()
  a_  					=							{"""feature-extraction""": MaskaFormerModel} if is_torch_available() else {}

  a_  					=							False
  a_  					=							False
  a_  					=							False
  a_  					=							False






  def        _a							(							self :       List[str] ):

        '''simple docstring'''




        A_						:  Tuple          =				MaskaFormerModelTester(self )
        A_						:  Dict          =				ConfigTester(self	,config_class=_a	,has_text_modality=_a )






  def        _a							(							self :       Dict ):

        '''simple docstring'''




        self.config_tester.run_common_tests()






  def        _a							(							self :       Optional[Any] ):

        '''simple docstring'''




        A_   ,					A_						:  Any          =				self.model_tester.prepare_config_and_inputs_for_common()
        self.model_tester.create_and_check_maskaformer_model(_a	,**_a	,output_hidden_states=_a )






  def        _a							(							self :       int ):

        '''simple docstring'''




        A_						:  str          =				self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_maskaformer_instance_segmentation_head_model(*_a )






  @unittest.skip(reason="""Mask2Former does not use inputs_embeds""" )
  def        _a							(							self :       List[str] ):

        '''simple docstring'''




        pass






  @unittest.skip(reason="""Mask2Former does not have a get_input_embeddings method""" )
  def        _a							(							self :       List[str] ):

        '''simple docstring'''




        pass






  @unittest.skip(reason="""Mask2Former is not a generative model""" )
  def        _a							(							self :       Optional[Any] ):

        '''simple docstring'''




        pass






  @unittest.skip(reason="""Mask2Former does not use token embeddings""" )
  def        _a							(							self :       Dict ):

        '''simple docstring'''




        pass






  @require_torch_multi_gpu
  @unittest.skip(
      reason="""Mask2Former has some layers using `add_module` which doesn't work well with `nn.DataParallel`""" )
  def        _a							(							self :       Any ):

        '''simple docstring'''




        pass






  @unittest.skip("""Will be fixed soon by reducing the size of the model used for common tests.""" )
  def        _a							(							self :       Union[str, Any] ):

        '''simple docstring'''




        pass






  def        _a							(							self :       str ):

        '''simple docstring'''




        A_   ,					A_						:  Any          =				self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
              A_						:  Optional[int]          =				model_class(_a )
              A_						:  str          =				inspect.signature(model.forward )
              # signature.parameters is an OrderedDict => so arg_names order is deterministic
              A_						:  List[str]          =				[*signature.parameters.keys()]

              A_						:  Optional[int]          =				["""pixel_values"""]
              self.assertListEqual(arg_names[:1]	,_a )






  @slow
  def        _a							(							self :       List[str] ):

        '''simple docstring'''




        for model_name in ["facebook/mask2former-swin-small-coco-instance"]:
              A_						:  str          =				MaskaFormerModel.from_pretrained(_a )
              self.assertIsNotNone(_a )






  def        _a							(							self :       str ):

        '''simple docstring'''




        A_						:  List[Any]          =				(self.model_tester.min_size,) * 2
        A_						:  Any          =				{
            """pixel_values""": torch.randn((2, 3, *size)	,device=_a ),
            """mask_labels""": torch.randn((2, 10, *size)	,device=_a ),
            """class_labels""": torch.zeros(2	,10	,device=_a ).long(),
        }
        A_						:  Optional[Any]          =				self.model_tester.get_config()

        A_						:  List[str]          =				MaskaFormerForUniversalSegmentation(_a ).to(_a )
        A_						:  int          =				model(**_a )
        self.assertTrue(outputs.loss is not None )






  def        _a							(							self :       Any ):

        '''simple docstring'''




        A_   ,					A_						:  Union[str, Any]          =				self.model_tester.prepare_config_and_inputs_for_common()
        self.model_tester.create_and_check_maskaformer_model(_a	,**_a	,output_hidden_states=_a )






  def        _a							(							self :       Tuple ):

        '''simple docstring'''




        A_   ,					A_						:  Any          =				self.model_tester.prepare_config_and_inputs_for_common()

        for model_class in self.all_model_classes:
              A_						:  Dict          =				model_class(_a ).to(_a )
              A_						:  Optional[int]          =				model(**_a	,output_attentions=_a )
              self.assertTrue(outputs.attentions is not None )






  def        _a							(							self :       Optional[int] ):

        '''simple docstring'''




        if not self.model_tester.is_training:
              return

        A_						:  List[Any]          =				self.all_model_classes[1]
        A_   ,					A_   ,					A_   ,					A_   ,					A_						:  int          =				self.model_tester.prepare_config_and_inputs()

        A_						:  Tuple          =				model_class(_a )
        model.to(_a )
        model.train()

        A_						:  Dict          =				model(_a	,mask_labels=_a	,class_labels=_a ).loss
        loss.backward()






  def        _a							(							self :       List[str] ):

        '''simple docstring'''




        A_						:  Dict          =				self.all_model_classes[1]
        A_   ,					A_   ,					A_   ,					A_   ,					A_						:  List[str]          =				self.model_tester.prepare_config_and_inputs()
        A_						:  int          =				True
        A_						:  Tuple          =				True

        A_						:  Union[str, Any]          =				model_class(_a ).to(_a )
        model.train()

        A_						:  Dict          =				model(_a	,mask_labels=_a	,class_labels=_a )

        A_						:  Optional[int]          =				outputs.encoder_hidden_states[0]
        encoder_hidden_states.retain_grad()

        A_						:  List[Any]          =				outputs.pixel_decoder_hidden_states[0]
        pixel_decoder_hidden_states.retain_grad()

        A_						:  int          =				outputs.transformer_decoder_hidden_states[0]
        transformer_decoder_hidden_states.retain_grad()

        A_						:  List[str]          =				outputs.attentions[0]
        attentions.retain_grad()

        outputs.loss.backward(retain_graph=_a )

        self.assertIsNotNone(encoder_hidden_states.grad )
        self.assertIsNotNone(pixel_decoder_hidden_states.grad )
        self.assertIsNotNone(transformer_decoder_hidden_states.grad )
        self.assertIsNotNone(attentions.grad )







__magic_name__			=      1e-4




def      lowerCamelCase					(      ):
      A_						:  List[str]          =				Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png""")
      return image






@require_vision
@slow
class 	__lowerCAmelCase		(							unittest.TestCase    ):


  '''simple docstring'''







  @cached_property
  def        _a							(							self :       Any ):

        '''simple docstring'''




        return "facebook/mask2former-swin-small-coco-instance"






  @cached_property
  def        _a							(							self :       Union[str, Any] ):

        '''simple docstring'''




        return MaskaFormerImageProcessor.from_pretrained(self.model_checkpoints ) if is_vision_available() else None






  def        _a							(							self :       Tuple ):

        '''simple docstring'''




        A_						:  Any          =				MaskaFormerModel.from_pretrained(self.model_checkpoints ).to(_a )
        A_						:  Dict          =				self.default_image_processor
        A_						:  Optional[int]          =				prepare_img()
        A_						:  Union[str, Any]          =				image_processor(_a	,return_tensors="""pt""" ).to(_a )
        A_						:  str          =				inputs["""pixel_values"""].shape
        # check size is divisible by 32
        self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0 )
        # check size
        self.assertEqual(_a	,(1, 3, 384, 384) )

        with torch.no_grad():
              A_						:  Union[str, Any]          =				model(**_a )

        A_						:  Tuple          =				torch.tensor(
            [[-0.2790, -1.0717, -1.1668], [-0.5128, -0.3128, -0.4987], [-0.5832, 0.1971, -0.0197]] ).to(_a )
        self.assertTrue(
            torch.allclose(
                outputs.encoder_last_hidden_state[0, 0, :3, :3]	,_a	,atol=_a ) )

        A_						:  Optional[Any]          =				torch.tensor(
            [[0.8973, 1.1847, 1.1776], [1.1934, 1.5040, 1.5128], [1.1153, 1.4486, 1.4951]] ).to(_a )
        self.assertTrue(
            torch.allclose(
                outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3]	,_a	,atol=_a ) )

        A_						:  str          =				torch.tensor(
            [[2.1152, 1.7000, -0.8603], [1.5808, 1.8004, -0.9353], [1.6043, 1.7495, -0.5999]] ).to(_a )
        self.assertTrue(
            torch.allclose(
                outputs.transformer_decoder_last_hidden_state[0, :3, :3]	,_a	,atol=_a ) )






  def        _a							(							self :       Optional[int] ):

        '''simple docstring'''




        A_						:  Dict          =				MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints ).to(_a ).eval()
        A_						:  str          =				self.default_image_processor
        A_						:  str          =				prepare_img()
        A_						:  str          =				image_processor(_a	,return_tensors="""pt""" ).to(_a )
        A_						:  Optional[Any]          =				inputs["""pixel_values"""].shape
        # check size is divisible by 32
        self.assertTrue((inputs_shape[-1] % 32) == 0 and (inputs_shape[-2] % 32) == 0 )
        # check size
        self.assertEqual(_a	,(1, 3, 384, 384) )

        with torch.no_grad():
              A_						:  str          =				model(**_a )
        # masks_queries_logits
        A_						:  Dict          =				outputs.masks_queries_logits
        self.assertEqual(
            masks_queries_logits.shape	,(1, model.config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4) )
        A_						:  List[str]          =				[
            [-8.7839, -9.0056, -8.8121],
            [-7.4104, -7.0313, -6.5401],
            [-6.6105, -6.3427, -6.4675],
        ]
        A_						:  Any          =				torch.tensor(_a ).to(_a )
        self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]	,_a	,atol=_a ) )
        # class_queries_logits
        A_						:  List[str]          =				outputs.class_queries_logits
        self.assertEqual(class_queries_logits.shape	,(1, model.config.num_queries, model.config.num_labels + 1) )
        A_						:  Dict          =				torch.tensor(
            [
                [1.8324, -8.0835, -4.1922],
                [0.8450, -9.0050, -3.6053],
                [0.3045, -7.7293, -3.0275],
            ] ).to(_a )
        self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]	,_a	,atol=_a ) )






  def        _a							(							self :       Optional[int] ):

        '''simple docstring'''




        A_						:  List[str]          =				MaskaFormerForUniversalSegmentation.from_pretrained(self.model_checkpoints ).to(_a ).eval()
        A_						:  Optional[int]          =				self.default_image_processor

        A_						:  Tuple          =				image_processor(
            [np.zeros((3, 800, 1333) ), np.zeros((3, 800, 1333) )]	,segmentation_maps=[np.zeros((384, 384) ).astype(np.floataa ), np.zeros((384, 384) ).astype(np.floataa )]	,return_tensors="""pt"""	,)

        A_						:  Optional[int]          =				inputs["""pixel_values"""].to(_a )
        A_						:  int          =				[el.to(_a ) for el in inputs["""mask_labels"""]]
        A_						:  Any          =				[el.to(_a ) for el in inputs["""class_labels"""]]

        with torch.no_grad():
              A_						:  Tuple          =				model(**_a )

        self.assertTrue(outputs.loss is not None )




'''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


__magic_name__			=      logging.get_logger(__name__)

__magic_name__			=      {
    '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 	__lowerCAmelCase		(							__SCREAMING_SNAKE_CASE    ):


  '''simple docstring'''







  a_  					=							"""owlvit_text_model"""






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

        '''simple docstring'''




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

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






  @classmethod
  def        _a							(							cls :       List[str]	,_a :       Union[str, os.PathLike]	,**_a :       str ):

        '''simple docstring'''




        cls._set_token_in_kwargs(_a )

        A_   ,					A_						:  int          =				cls.get_config_dict(_a	,**_a )

        # get the text config dict if we are loading from OwlViTConfig
        if config_dict.get("""model_type""" ) == "owlvit":
              A_						:  Union[str, Any]          =				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(_a	,**_a )







class 	__lowerCAmelCase		(							__SCREAMING_SNAKE_CASE    ):


  '''simple docstring'''







  a_  					=							"""owlvit_vision_model"""






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

        '''simple docstring'''




        super().__init__(**_a )

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






  @classmethod
  def        _a							(							cls :       List[Any]	,_a :       Union[str, os.PathLike]	,**_a :       str ):

        '''simple docstring'''




        cls._set_token_in_kwargs(_a )

        A_   ,					A_						:  Optional[int]          =				cls.get_config_dict(_a	,**_a )

        # get the vision config dict if we are loading from OwlViTConfig
        if config_dict.get("""model_type""" ) == "owlvit":
              A_						:  List[str]          =				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(_a	,**_a )







class 	__lowerCAmelCase		(							__SCREAMING_SNAKE_CASE    ):


  '''simple docstring'''







  a_  					=							"""owlvit"""
  a_  					=							True






  def __init__(							self :       Union[str, Any]	,_a :       List[str]=None	,_a :       List[str]=None	,_a :       Dict=512	,_a :       List[Any]=2.6592	,_a :       Optional[Any]=True	,**_a :       Optional[int]	,):

        '''simple docstring'''




        super().__init__(**_a )

        if text_config is None:
              A_						:  List[Any]          =				{}
              logger.info("""text_config is None. Initializing the OwlViTTextConfig with default values.""" )

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

        A_						:  Dict          =				OwlViTTextConfig(**_a )
        A_						:  Dict          =				OwlViTVisionConfig(**_a )

        A_						:  Any          =				projection_dim
        A_						:  Optional[int]          =				logit_scale_init_value
        A_						:  Optional[int]          =				return_dict
        A_						:  Dict          =				1.0






  @classmethod
  def        _a							(							cls :       Union[str, Any]	,_a :       Union[str, os.PathLike]	,**_a :       Optional[int] ):

        '''simple docstring'''




        cls._set_token_in_kwargs(_a )

        A_   ,					A_						:  List[Any]          =				cls.get_config_dict(_a	,**_a )

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






  @classmethod
  def        _a							(							cls :       int	,_a :       Dict	,_a :       Dict	,**_a :       List[str] ):

        '''simple docstring'''




        A_						:  str          =				{}
        A_						:  int          =				text_config
        A_						:  Union[str, Any]          =				vision_config

        return cls.from_dict(_a	,**_a )






  def        _a							(							self :       Optional[int] ):

        '''simple docstring'''




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







class 	__lowerCAmelCase		(							__SCREAMING_SNAKE_CASE    ):


  '''simple docstring'''







  @property
  def        _a							(							self :       int ):

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

        '''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 :       Optional[Any] ):

        '''simple docstring'''




        return 1e-4






  def        _a							(							self :       int	,_a :       "ProcessorMixin"	,_a :       int = -1	,_a :       int = -1	,_a :       Optional["TensorType"] = None	,):

        '''simple docstring'''




        A_						:  Any          =				super().generate_dummy_inputs(
            processor.tokenizer	,batch_size=_a	,seq_length=_a	,framework=_a )
        A_						:  Any          =				super().generate_dummy_inputs(
            processor.image_processor	,batch_size=_a	,framework=_a )
        return {**text_input_dict, **image_input_dict}






  @property
  def        _a							(							self :       Optional[Any] ):

        '''simple docstring'''




        return 14
