code: def test_inference_instance_segmentation_head(self):
      model = (
          MaskFormerForInstanceSegmentation.from_pretrained(
              "facebook/maskformer-swin-small-coco"
          )
          .to(torch_device)
          .eval()
      )
      image_processor = self.default_image_processor
      image = prepare_img()
      inputs = image_processor(image, return_tensors="pt").to(
          torch_device
      )
      inputs_shape = 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(inputs_shape, (1, 3, 800, 1088))
  
      with torch.no_grad():
          outputs = model(**inputs)
      # masks_queries_logits
      masks_queries_logits = 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,
          ),
      )
      expected_slice = [
          [-1.3737124, -1.7724937, -1.9364233],
          [-1.5977281, -1.9867939, -2.1523695],
          [-1.5795398, -1.9269832, -2.093942],
      ]
      expected_slice = torch.tensor(expected_slice).to(torch_device)
      self.assertTrue(
          torch.allclose(
              masks_queries_logits[0, 0, :3, :3],
              expected_slice,
              atol=TOLERANCE,
          )
      )
      # class_queries_logits
      class_queries_logits = outputs.class_queries_logits
      self.assertEqual(
          class_queries_logits.shape,
          (
              1,
              model.config.decoder_config.num_queries,
              model.config.num_labels + 1,
          ),
      )
      expected_slice = torch.tensor(
          [
              [1.6512e00, -5.2572e00, -3.3519e00],
              [3.6169e-02, -5.9025e00, -2.9313e00],
              [1.0766e-04, -7.7630e00, -5.1263e00],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.class_queries_logits[0, :3, :3],
              expected_slice,
              atol=TOLERANCE,
          )
      )
  
imports: import copy
  import unittest
  import numpy
  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_accelerator, require_torch_fp16, 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
label_desc: Use image node_id 3 for calling the MaskFormerModelIntegrationTest obj's underlying member method code with example usage: obj.test_inference_instance_segmentation_head() without return types