code: def test_table_detection(self):
      feature_extractor = AutoFeatureExtractor.from_pretrained(
          "microsoft/table-transformer-detection"
      )
      model = TableTransformerForObjectDetection.from_pretrained(
          "microsoft/table-transformer-detection"
      )
      model.to(torch_device)
  
      file_path = hf_hub_download(
          repo_id="nielsr/example-pdf",
          repo_type="dataset",
          filename="example_pdf.png",
      )
      image = Image.open(file_path).convert("RGB")
      inputs = feature_extractor(image, return_tensors="pt").to(
          torch_device
      )
  
      # forward pass
      with torch.no_grad():
          outputs = model(**inputs)
  
      expected_shape = (1, 15, 3)
      self.assertEqual(outputs.logits.shape, expected_shape)
  
      expected_logits = torch.tensor(
          [
              [-6.7329, -16.9590, 6.7447],
              [-8.0038, -22.3071, 6.9288],
              [-7.2445, -20.9855, 7.3465],
          ],
          device=torch_device,
      )
      self.assertTrue(
          torch.allclose(
              outputs.logits[0, :3, :3], expected_logits, atol=1e-4
          )
      )
  
      expected_boxes = torch.tensor(
          [
              [0.4868, 0.1764, 0.6729],
              [0.6674, 0.4621, 0.3864],
              [0.4720, 0.1757, 0.6362],
          ],
          device=torch_device,
      )
      self.assertTrue(
          torch.allclose(
              outputs.pred_boxes[0, :3, :3], expected_boxes, atol=1e-3
          )
      )
  
imports: import inspect
  import math
  import unittest
  from huggingface_hub import hf_hub_download
  from transformers import TableTransformerConfig, is_timm_available, is_vision_available
  from transformers.testing_utils import require_timm, require_vision, slow, torch_device
  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 1 for calling the TableTransformerModelIntegrationTests obj's underlying member method code with example usage: obj.test_table_detection() without return types