code: def test_inference_object_detection_head_with_box_refine_two_stage(
      self,
  ):
      model = DeformableDetrForObjectDetection.from_pretrained(
          "SenseTime/deformable-detr-with-box-refine-two-stage"
      ).to(torch_device)
  
      image_processor = self.default_image_processor
      image = prepare_img()
      encoding = image_processor(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)
      )
      self.assertEqual(outputs.logits.shape, expected_shape_logits)
  
      expected_logits = torch.tensor(
          [
              [-6.7108, -4.3213, -6.3777],
              [-8.9014, -6.1799, -6.7240],
              [-6.9315, -4.4735, -6.2298],
          ]
      ).to(torch_device)
      expected_boxes = torch.tensor(
          [
              [0.2583, 0.5499, 0.4683],
              [0.7652, 0.9068, 0.4882],
              [0.5490, 0.2763, 0.0564],
          ]
      ).to(torch_device)
  
      self.assertTrue(
          torch.allclose(
              outputs.logits[0, :3, :3], expected_logits, atol=1e-4
          )
      )
  
      expected_shape_boxes = torch.Size(
          (1, model.config.num_queries, 4)
      )
      self.assertEqual(outputs.pred_boxes.shape, expected_shape_boxes)
      self.assertTrue(
          torch.allclose(
              outputs.pred_boxes[0, :3, :3], expected_boxes, atol=1e-4
          )
      )
  
imports: import inspect
  import math
  import unittest
  from typing import Dict, List, Tuple
  from transformers import DeformableDetrConfig, ResNetConfig, is_torch_available, is_vision_available
  from transformers.file_utils import cached_property
  from transformers.testing_utils import require_timm, require_torch, require_torch_accelerator, require_vision, slow, torch_device
  from ...generation.test_utils import GenerationTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 3 for calling the DeformableDetrModelIntegrationTests obj's underlying member method code with example usage: obj.test_inference_object_detection_head_with_box_refine_two_stage() without return types