code: def test_inference_panoptic_segmentation_head(self):
      model = DetrForSegmentation.from_pretrained(
          "facebook/detr-resnet-50-panoptic"
      ).to(torch_device)
  
      feature_extractor = self.default_feature_extractor
      image = prepare_img()
      encoding = feature_extractor(
          images=image, return_tensors="pt"
      ).to(torch_device)
      pixel_values = encoding["pixel_values"].to(torch_device)
      pixel_mask = encoding["pixel_mask"].to(torch_device)
  
      with torch.no_grad():
          outputs = model(pixel_values, pixel_mask)
  
      expected_shape_logits = torch.Size(
          (1, model.config.num_queries, model.config.num_labels + 1)
      )
      self.assertEqual(outputs.logits.shape, expected_shape_logits)
      expected_slice_logits = torch.tensor(
          [
              [-18.1565, -1.7568, -13.5029],
              [-16.8888, -1.4138, -14.1028],
              [-17.5709, -2.5080, -11.8654],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.logits[0, :3, :3],
              expected_slice_logits,
              atol=1e-4,
          )
      )
  
      expected_shape_boxes = torch.Size(
          (1, model.config.num_queries, 4)
      )
      self.assertEqual(outputs.pred_boxes.shape, expected_shape_boxes)
      expected_slice_boxes = torch.tensor(
          [
              [0.5344, 0.1789, 0.9285],
              [0.4420, 0.0572, 0.0875],
              [0.6630, 0.6887, 0.1017],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.pred_boxes[0, :3, :3],
              expected_slice_boxes,
              atol=1e-4,
          )
      )
  
      expected_shape_masks = torch.Size(
          (1, model.config.num_queries, 200, 267)
      )
      self.assertEqual(outputs.pred_masks.shape, expected_shape_masks)
      expected_slice_masks = torch.tensor(
          [
              [-7.7558, -10.8788, -11.9797],
              [-11.8881, -16.4329, -17.7451],
              [-14.7316, -19.7383, -20.3004],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.pred_masks[0, 0, :3, :3],
              expected_slice_masks,
              atol=1e-3,
          )
      )
  
imports: import inspect
  import math
  import unittest
  from transformers import DetrConfig, is_timm_available, is_vision_available
  from transformers.testing_utils import require_timm, require_vision, slow, torch_device
  from transformers.utils import cached_property
  from ...generation.test_generation_utils import GenerationTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor
label_desc: Use image node_id 4 for calling the DetrModelIntegrationTests obj's underlying member method code with example usage: obj.test_inference_panoptic_segmentation_head() without return types