code: def test_default_anchor_generator_centered(self):
      # test explicit args
      anchor_generator = DefaultAnchorGenerator(
          sizes=[32, 64], aspect_ratios=[0.25, 1, 4], strides=[4]
      )
  
      # only the last two dimensions of features matter here
      num_images = 2
      features = {"stage3": torch.rand(num_images, 96, 1, 2)}
      expected_anchor_tensor = torch.tensor(
          [
              [-30.0, -6.0, 34.0, 10.0],
              [-14.0, -14.0, 18.0, 18.0],
              [-6.0, -30.0, 10.0, 34.0],
              [-62.0, -14.0, 66.0, 18.0],
              [-30.0, -30.0, 34.0, 34.0],
              [-14.0, -62.0, 18.0, 66.0],
              [-26.0, -6.0, 38.0, 10.0],
              [-10.0, -14.0, 22.0, 18.0],
              [-2.0, -30.0, 14.0, 34.0],
              [-58.0, -14.0, 70.0, 18.0],
              [-26.0, -30.0, 38.0, 34.0],
              [-10.0, -62.0, 22.0, 66.0],
          ]
      )
  
      anchors = anchor_generator([features["stage3"]])
      self.assertTrue(
          torch.allclose(anchors[0].tensor, expected_anchor_tensor)
      )
  
      anchors = torch.jit.script(anchor_generator)([features["stage3"]])
      self.assertTrue(
          torch.allclose(anchors[0].tensor, expected_anchor_tensor)
      )
  
file_path: detectron2/tests/modeling/test_anchor_generator.py
imports: import logging
  import unittest
  import torch
  from detectron2.config import get_cfg
  from detectron2.layers import ShapeSpec
  from detectron2.modeling.anchor_generator import DefaultAnchorGenerator, RotatedAnchorGenerator
label_desc: Use image node_id 2 for calling the TestAnchorGenerator obj's underlying member method code with example usage: obj.test_default_anchor_generator_centered() without return types