code: def test_inference_object_detection_head(self):
      model = ConditionalDetrForObjectDetection.from_pretrained(
          "microsoft/conditional-detr-resnet-50"
      ).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)
  
      # verify logits + box predictions
      expected_shape_logits = torch.Size(
          (1, model.config.num_queries, model.config.num_labels)
      )
      self.assertEqual(outputs.logits.shape, expected_shape_logits)
      expected_slice_logits = torch.tensor(
          [
              [-10.4372, -5.7558, -8.6764],
              [-10.5410, -5.8704, -8.0590],
              [-10.6827, -6.3469, -8.3923],
          ]
      ).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.7733, 0.6576, 0.4496],
              [0.5171, 0.1184, 0.9094],
              [0.8846, 0.5647, 0.2486],
          ]
      ).to(torch_device)
      self.assertTrue(
          torch.allclose(
              outputs.pred_boxes[0, :3, :3],
              expected_slice_boxes,
              atol=1e-4,
          )
      )
  
      # verify postprocessing
      results = feature_extractor.post_process_object_detection(
          outputs, threshold=0.3, target_sizes=[image.size[::-1]]
      )[0]
      expected_scores = torch.tensor(
          [0.8330, 0.8313, 0.8039, 0.6829, 0.5355]
      )
      expected_labels = [75, 17, 17, 75, 63]
      expected_slice_boxes = torch.tensor(
          [38.3089, 72.1022, 177.6293, 118.4512]
      )
  
      self.assertEqual(len(results["scores"]), 5)
      self.assertTrue(
          torch.allclose(results["scores"], expected_scores, atol=1e-4)
      )
      self.assertSequenceEqual(
          results["labels"].tolist(), expected_labels
      )
      self.assertTrue(
          torch.allclose(results["boxes"][0, :], expected_slice_boxes)
      )
  
imports: import inspect
  import math
  import unittest
  from transformers import ConditionalDetrConfig, 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 3 for calling the ConditionalDetrModelIntegrationTests obj's underlying member method code with example usage: obj.test_inference_object_detection_head() without return types