



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


A_		:     int        =     {
    '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''],
    '''tokenization_xlm''': ['''XLMTokenizer'''],
}

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A_		:     List[str]        =     [
         '''XLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''XLMForMultipleChoice''',
         '''XLMForQuestionAnswering''',
         '''XLMForQuestionAnsweringSimple''',
         '''XLMForSequenceClassification''',
         '''XLMForTokenClassification''',
         '''XLMModel''',
         '''XLMPreTrainedModel''',
         '''XLMWithLMHeadModel''',
     ]

try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A_		:     int        =     [
         '''TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''TFXLMForMultipleChoice''',
         '''TFXLMForQuestionAnsweringSimple''',
         '''TFXLMForSequenceClassification''',
         '''TFXLMForTokenClassification''',
         '''TFXLMMainLayer''',
         '''TFXLMModel''',
         '''TFXLMPreTrainedModel''',
         '''TFXLMWithLMHeadModel''',
     ]


if TYPE_CHECKING:
     from .configuration_xlm import XLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XLMConfig, XLMOnnxConfig
     from .tokenization_xlm import XLMTokenizer

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_xlm import (
              XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
              XLMForMultipleChoice,
              XLMForQuestionAnswering,
              XLMForQuestionAnsweringSimple,
              XLMForSequenceClassification,
              XLMForTokenClassification,
              XLMModel,
              XLMPreTrainedModel,
              XLMWithLMHeadModel,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_xlm import (
              TF_XLM_PRETRAINED_MODEL_ARCHIVE_LIST,
              TFXLMForMultipleChoice,
              TFXLMForQuestionAnsweringSimple,
              TFXLMForSequenceClassification,
              TFXLMForTokenClassification,
              TFXLMMainLayer,
              TFXLMModel,
              TFXLMPreTrainedModel,
              TFXLMWithLMHeadModel,
          )

else:
     import sys

     A_		:     Dict        =     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)






import inspect
import unittest

import numpy as np

from tests.test_modeling_common import floats_tensor
from transformers import DetrConfig, MaskFormerConfig, SwinConfig, 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 MaskFormerForInstanceSegmentation, MaskFormerModel

     if is_vision_available():
          from transformers import MaskFormerImageProcessor

if is_vision_available():
     from PIL import Image



class 		_lowercase		:

   def __init__(      self			:       Any							,   __lowerCAmelCase			:       Any							,   __lowerCAmelCase			:       Tuple=2							,   __lowerCAmelCase			:       Optional[int]=True							,   __lowerCAmelCase			:       Optional[int]=False							,   __lowerCAmelCase			:       int=10							,   __lowerCAmelCase			:       Any=3							,   __lowerCAmelCase			:       Optional[int]=32 * 4							,   __lowerCAmelCase			:       Dict=32 * 6							,   __lowerCAmelCase			:       str=4							,   __lowerCAmelCase			:       Dict=32							,   )       ->				Any:


    """simple docstring"""






    a						=		parent
    a						=		batch_size
    a						=		is_training
    a						=		use_auxiliary_loss
    a						=		num_queries
    a						=		num_channels
    a						=		min_size
    a						=		max_size
    a						=		num_labels
    a						=		mask_feature_size

   def 		A							(      self			:       Union[str, Any]							)       ->				Dict:


    """simple docstring"""






    a						=		floats_tensor([self.batch_size, self.num_channels, self.min_size, self.max_size]							).to(
        __lowerCAmelCase							)

    a						=		torch.ones([self.batch_size, self.min_size, self.max_size]							,   device=__lowerCAmelCase							)

    a						=		(
        torch.rand([self.batch_size, self.num_labels, self.min_size, self.max_size]							,   device=__lowerCAmelCase							) > 0.5
    ).float()
    a						=		(torch.rand((self.batch_size, self.num_labels)							,   device=__lowerCAmelCase							) > 0.5).long()

    a						=		self.get_config()
    return config, pixel_values, pixel_mask, mask_labels, class_labels

   def 		A							(      self			:       str							)       ->				Any:


    """simple docstring"""






    return MaskFormerConfig.from_backbone_and_decoder_configs(
        backbone_config=SwinConfig(
            depths=[1, 1, 1, 1]							,   )							,   decoder_config=DetrConfig(
            decoder_ffn_dim=128							,   num_queries=self.num_queries							,   decoder_attention_heads=2							,   d_model=self.mask_feature_size							,   )							,   mask_feature_size=self.mask_feature_size							,   fpn_feature_size=self.mask_feature_size							,   num_channels=self.num_channels							,   num_labels=self.num_labels							,   )

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


    """simple docstring"""






    a		,  a		,  a		,  a		,  a						=		self.prepare_config_and_inputs()
    a						=		{"pixel_values": pixel_values, "pixel_mask": pixel_mask}
    return config, inputs_dict

   def 		A							(      self			:       Tuple							,   __lowerCAmelCase			:       Any							,   __lowerCAmelCase			:       Dict							)       ->				str:


    """simple docstring"""






    a						=		output.encoder_hidden_states
    a						=		output.pixel_decoder_hidden_states
    a						=		output.transformer_decoder_hidden_states

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

   def 		A							(      self			:       List[str]							,   __lowerCAmelCase			:       List[str]							,   __lowerCAmelCase			:       Dict							,   __lowerCAmelCase			:       Union[str, Any]							,   __lowerCAmelCase			:       List[str]=False							)       ->				Tuple:


    """simple docstring"""






    with torch.no_grad():
     a						=		MaskFormerModel(config=__lowerCAmelCase							)
     model.to(__lowerCAmelCase							)
     model.eval()

     a						=		model(pixel_values=__lowerCAmelCase							,   pixel_mask=__lowerCAmelCase							)
     a						=		model(__lowerCAmelCase							,   output_hidden_states=__lowerCAmelCase							)
    # the correct shape of output.transformer_decoder_hidden_states ensure the correcteness of the
    # encoder and pixel decoder
    self.parent.assertEqual(
        output.transformer_decoder_last_hidden_state.shape							,   (self.batch_size, self.num_queries, self.mask_feature_size)							,   )
    # 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(__lowerCAmelCase							,   __lowerCAmelCase							)




   def 		A							(      self			:       List[str]							,   __lowerCAmelCase			:       str							,   __lowerCAmelCase			:       List[Any]							,   __lowerCAmelCase			:       int							,   __lowerCAmelCase			:       Any							,   __lowerCAmelCase			:       List[str]							)       ->				Optional[int]:


    """simple docstring"""






    a						=		MaskFormerForInstanceSegmentation(config=__lowerCAmelCase							)
    model.to(__lowerCAmelCase							)
    model.eval()

    def comm_check_on_output(__lowerCAmelCase			:       Tuple							):
     # 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						=		model(pixel_values=__lowerCAmelCase							,   pixel_mask=__lowerCAmelCase							)
     a						=		model(__lowerCAmelCase							)

     comm_check_on_output(__lowerCAmelCase							)

     a						=		model(
         pixel_values=__lowerCAmelCase							,   pixel_mask=__lowerCAmelCase							,   mask_labels=__lowerCAmelCase							,   class_labels=__lowerCAmelCase							)

    comm_check_on_output(__lowerCAmelCase							)

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



@require_torch
class 		_lowercase		(       UpperCAmelCase__,   UpperCAmelCase__,   unittest.TestCase	):
   _UpperCAmelCase     	=			(MaskFormerModel, MaskFormerForInstanceSegmentation) if is_torch_available() else ()
   _UpperCAmelCase     	=			(
       {'''feature-extraction''': MaskFormerModel, '''image-segmentation''': MaskFormerForInstanceSegmentation}
       if is_torch_available()
       else {}
   )

   _UpperCAmelCase     	=			False
   _UpperCAmelCase     	=			False
   _UpperCAmelCase     	=			False
   _UpperCAmelCase     	=			False

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


    """simple docstring"""






    a						=		MaskFormerModelTester(self							)
    a						=		ConfigTester(self							,   config_class=__lowerCAmelCase							,   has_text_modality=__lowerCAmelCase							)

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


    """simple docstring"""






    self.config_tester.run_common_tests()

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


    """simple docstring"""






    a		,  a						=		self.model_tester.prepare_config_and_inputs_for_common()
    self.model_tester.create_and_check_maskformer_model(__lowerCAmelCase							,   **__lowerCAmelCase							,   output_hidden_states=__lowerCAmelCase							)

   def 		A							(      self			:       int							)       ->				int:


    """simple docstring"""






    a						=		self.model_tester.prepare_config_and_inputs()
    self.model_tester.create_and_check_maskformer_instance_segmentation_head_model(*__lowerCAmelCase							)

   @unittest.skip(reason="MaskFormer does not use inputs_embeds"							)
   def 		A							(      self			:       List[Any]							)       ->				Optional[Any]:


    """simple docstring"""






    pass

   @unittest.skip(reason="MaskFormer does not have a get_input_embeddings method"							)
   def 		A							(      self			:       str							)       ->				Union[str, Any]:


    """simple docstring"""






    pass

   @unittest.skip(reason="MaskFormer is not a generative model"							)
   def 		A							(      self			:       Tuple							)       ->				Optional[Any]:


    """simple docstring"""






    pass

   @unittest.skip(reason="MaskFormer does not use token embeddings"							)
   def 		A							(      self			:       Tuple							)       ->				Optional[Any]:


    """simple docstring"""






    pass

   @require_torch_multi_gpu
   @unittest.skip(
       reason="MaskFormer has some layers using `add_module` which doesn't work well with `nn.DataParallel`"							)
   def 		A							(      self			:       Optional[int]							)       ->				List[str]:


    """simple docstring"""






    pass

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


    """simple docstring"""






    pass

   def 		A							(      self			:       Optional[Any]							)       ->				Optional[Any]:


    """simple docstring"""






    a		,  a						=		self.model_tester.prepare_config_and_inputs_for_common()

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

     a						=		["pixel_values"]
     self.assertListEqual(arg_names[:1]							,   __lowerCAmelCase							)

   @slow
   def 		A							(      self			:       Tuple							)       ->				List[Any]:


    """simple docstring"""






    for model_name in ["facebook/maskformer-swin-small-coco"]:
     a						=		MaskFormerModel.from_pretrained(__lowerCAmelCase							)
     self.assertIsNotNone(__lowerCAmelCase							)

   def 		A							(      self			:       str							)       ->				Dict:


    """simple docstring"""






    a						=		(self.model_tester.min_size,) * 2
    a						=		{
        "pixel_values": torch.randn((2, 3, *size)							,   device=__lowerCAmelCase							),
        "mask_labels": torch.randn((2, 10, *size)							,   device=__lowerCAmelCase							),
        "class_labels": torch.zeros(2							,   10							,   device=__lowerCAmelCase							).long(),
    }

    a						=		MaskFormerForInstanceSegmentation(MaskFormerConfig()							).to(__lowerCAmelCase							)
    a						=		model(**__lowerCAmelCase							)
    self.assertTrue(outputs.loss is not None							)

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


    """simple docstring"""






    a		,  a						=		self.model_tester.prepare_config_and_inputs_for_common()
    self.model_tester.create_and_check_maskformer_model(__lowerCAmelCase							,   **__lowerCAmelCase							,   output_hidden_states=__lowerCAmelCase							)

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


    """simple docstring"""






    a		,  a						=		self.model_tester.prepare_config_and_inputs_for_common()

    for model_class in self.all_model_classes:
     a						=		model_class(__lowerCAmelCase							).to(__lowerCAmelCase							)
     a						=		model(**__lowerCAmelCase							,   output_attentions=__lowerCAmelCase							)
     self.assertTrue(outputs.attentions is not None							)

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


    """simple docstring"""






    if not self.model_tester.is_training:
     return
    # only MaskFormerForInstanceSegmentation has the loss
    a						=		self.all_model_classes[1]
    a		,  a		,  a		,  a		,  a						=		self.model_tester.prepare_config_and_inputs()

    a						=		model_class(__lowerCAmelCase							)
    model.to(__lowerCAmelCase							)
    model.train()

    a						=		model(__lowerCAmelCase							,   mask_labels=__lowerCAmelCase							,   class_labels=__lowerCAmelCase							).loss
    loss.backward()




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


    """simple docstring"""






    a						=		self.all_model_classes[1]
    a		,  a		,  a		,  a		,  a						=		self.model_tester.prepare_config_and_inputs()
    a						=		True
    a						=		True

    a						=		model_class(__lowerCAmelCase							)
    model.to(__lowerCAmelCase							)
    model.train()

    a						=		model(__lowerCAmelCase							,   mask_labels=__lowerCAmelCase							,   class_labels=__lowerCAmelCase							)

    a						=		outputs.encoder_hidden_states[0]
    encoder_hidden_states.retain_grad()

    a						=		outputs.pixel_decoder_hidden_states[0]
    pixel_decoder_hidden_states.retain_grad()
    # we requires_grad=True in inputs_embeds (line 2152), the original implementation don't
    a						=		outputs.transformer_decoder_hidden_states[0]
    transformer_decoder_hidden_states.retain_grad()

    a						=		outputs.attentions[0]
    attentions.retain_grad()

    outputs.loss.backward(retain_graph=__lowerCAmelCase							)

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

A_		:     int        =     1E-4


def 	UpperCAmelCase__      (      ):






 '''simple docstring'''

 a						=		Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"					)
 return image




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

   @cached_property
   def 		A							(      self			:       int							)       ->				Optional[int]:


    """simple docstring"""






    return (
        MaskFormerImageProcessor.from_pretrained("facebook/maskformer-swin-small-coco"							)
        if is_vision_available()
        else None
    )

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


    """simple docstring"""






    a						=		MaskFormerModel.from_pretrained("facebook/maskformer-swin-small-coco"							).to(__lowerCAmelCase							)
    a						=		self.default_image_processor
    a						=		prepare_img()
    a						=		image_processor(__lowerCAmelCase							,   return_tensors="pt"							).to(__lowerCAmelCase							)
    a						=		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(__lowerCAmelCase							,   (1, 3, 800, 1088)							)

    with torch.no_grad():
     a						=		model(**__lowerCAmelCase							)

    a						=		torch.tensor(
        [[-0.0_4_8_2, 0.9_2_2_8, 0.4_9_5_1], [-0.2_5_4_7, 0.8_0_1_7, 0.8_5_2_7], [-0.0_0_6_9, 0.3_3_8_5, -0.0_0_8_9]]							).to(__lowerCAmelCase							)
    self.assertTrue(
        torch.allclose(
            outputs.encoder_last_hidden_state[0, 0, :3, :3]							,   __lowerCAmelCase							,   atol=__lowerCAmelCase							)							)

    a						=		torch.tensor(
        [[-0.8_4_2_2, -0.8_4_3_4, -0.9_7_1_8], [-1.0_1_4_4, -0.5_5_6_5, -0.4_1_9_5], [-1.0_0_3_8, -0.4_4_8_4, -0.1_9_6_1]]							).to(__lowerCAmelCase							)
    self.assertTrue(
        torch.allclose(
            outputs.pixel_decoder_last_hidden_state[0, 0, :3, :3]							,   __lowerCAmelCase							,   atol=__lowerCAmelCase							)							)

    a						=		torch.tensor(
        [[0.2_8_5_2, -0.0_1_5_9, 0.9_7_3_5], [0.6_2_5_4, 0.1_8_5_8, 0.8_5_2_9], [-0.0_6_8_0, -0.4_1_1_6, 1.8_4_1_3]]							).to(__lowerCAmelCase							)
    self.assertTrue(
        torch.allclose(
            outputs.transformer_decoder_last_hidden_state[0, :3, :3]							,   __lowerCAmelCase							,   atol=__lowerCAmelCase							)							)

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


    """simple docstring"""






    a						=		(
        MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-swin-small-coco"							)
        .to(__lowerCAmelCase							)
        .eval()
    )
    a						=		self.default_image_processor
    a						=		prepare_img()
    a						=		image_processor(__lowerCAmelCase							,   return_tensors="pt"							).to(__lowerCAmelCase							)
    a						=		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(__lowerCAmelCase							,   (1, 3, 800, 1088)							)

    with torch.no_grad():
     a						=		model(**__lowerCAmelCase							)
    # masks_queries_logits
    a						=		outputs.masks_queries_logits
    self.assertEqual(
        masks_queries_logits.shape							,   (1, model.config.decoder_config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)							,   )
    a						=		[
        [-1.3_7_3_7_1_2_4, -1.7_7_2_4_9_3_7, -1.9_3_6_4_2_3_3],
        [-1.5_9_7_7_2_8_1, -1.9_8_6_7_9_3_9, -2.1_5_2_3_6_9_5],
        [-1.5_7_9_5_3_9_8, -1.9_2_6_9_8_3_2, -2.0_9_3_9_4_2],
    ]
    a						=		torch.tensor(__lowerCAmelCase							).to(__lowerCAmelCase							)
    self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]							,   __lowerCAmelCase							,   atol=__lowerCAmelCase							)							)
    # class_queries_logits
    a						=		outputs.class_queries_logits
    self.assertEqual(
        class_queries_logits.shape							,   (1, model.config.decoder_config.num_queries, model.config.num_labels + 1)							)
    a						=		torch.tensor(
        [
            [1.65_12E00, -5.25_72E00, -3.35_19E00],
            [3.61_69E-02, -5.90_25E00, -2.93_13E00],
            [1.07_66E-04, -7.76_30E00, -5.12_63E00],
        ]							).to(__lowerCAmelCase							)
    self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]							,   __lowerCAmelCase							,   atol=__lowerCAmelCase							)							)

   def 		A							(      self			:       List[Any]							)       ->				Any:


    """simple docstring"""






    a						=		(
        MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-resnet101-coco-stuff"							)
        .to(__lowerCAmelCase							)
        .eval()
    )
    a						=		self.default_image_processor
    a						=		prepare_img()
    a						=		image_processor(__lowerCAmelCase							,   return_tensors="pt"							).to(__lowerCAmelCase							)
    a						=		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(__lowerCAmelCase							,   (1, 3, 800, 1088)							)

    with torch.no_grad():
     a						=		model(**__lowerCAmelCase							)
    # masks_queries_logits
    a						=		outputs.masks_queries_logits
    self.assertEqual(
        masks_queries_logits.shape							,   (1, model.config.decoder_config.num_queries, inputs_shape[-2] // 4, inputs_shape[-1] // 4)							,   )
    a						=		[[-0.9_0_4_6, -2.6_3_6_6, -4.6_0_6_2], [-3.4_1_7_9, -5.7_8_9_0, -8.8_0_5_7], [-4.9_1_7_9, -7.6_5_6_0, -1_0.7_7_1_1]]
    a						=		torch.tensor(__lowerCAmelCase							).to(__lowerCAmelCase							)
    self.assertTrue(torch.allclose(masks_queries_logits[0, 0, :3, :3]							,   __lowerCAmelCase							,   atol=__lowerCAmelCase							)							)
    # class_queries_logits
    a						=		outputs.class_queries_logits
    self.assertEqual(
        class_queries_logits.shape							,   (1, model.config.decoder_config.num_queries, model.config.num_labels + 1)							)
    a						=		torch.tensor(
        [[4.7_1_8_8, -3.2_5_8_5, -2.8_8_5_7], [6.6_8_7_1, -2.9_1_8_1, -1.2_4_8_7], [7.2_4_4_9, -2.2_7_6_4, -2.1_8_7_4]]							).to(__lowerCAmelCase							)
    self.assertTrue(torch.allclose(outputs.class_queries_logits[0, :3, :3]							,   __lowerCAmelCase							,   atol=__lowerCAmelCase							)							)




   def 		A							(      self			:       int							)       ->				Any:


    """simple docstring"""






    a						=		(
        MaskFormerForInstanceSegmentation.from_pretrained("facebook/maskformer-swin-small-coco"							)
        .to(__lowerCAmelCase							)
        .eval()
    )
    a						=		self.default_image_processor

    a						=		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						=		inputs["pixel_values"].to(__lowerCAmelCase							)
    a						=		[el.to(__lowerCAmelCase							) for el in inputs["mask_labels"]]
    a						=		[el.to(__lowerCAmelCase							) for el in inputs["class_labels"]]

    with torch.no_grad():
     a						=		model(**__lowerCAmelCase							)

    self.assertTrue(outputs.loss is not None							)

