code: def _test_roialignv2_roialignrotated_match(self, device):
      pooler_resolution = 14
      canonical_level = 4
      canonical_scale_factor = 2**canonical_level
      pooler_scales = (1.0 / canonical_scale_factor,)
      sampling_ratio = 0
  
      N, C, H, W = 2, 4, 10, 8
      N_rois = 10
      std = 11
      mean = 0
      feature = (torch.rand(N, C, H, W) - 0.5) * 2 * std + mean
  
      features = [feature.to(device)]
  
      rois = []
      rois_rotated = []
      for _ in range(N):
          boxes = random_boxes(N_rois, W * canonical_scale_factor)
          rotated_boxes = torch.zeros(N_rois, 5)
          rotated_boxes[:, 0] = (boxes[:, 0] + boxes[:, 2]) / 2.0
          rotated_boxes[:, 1] = (boxes[:, 1] + boxes[:, 3]) / 2.0
          rotated_boxes[:, 2] = boxes[:, 2] - boxes[:, 0]
          rotated_boxes[:, 3] = boxes[:, 3] - boxes[:, 1]
          rois.append(Boxes(boxes).to(device))
          rois_rotated.append(RotatedBoxes(rotated_boxes).to(device))
  
      roialignv2_pooler = ROIPooler(
          output_size=pooler_resolution,
          scales=pooler_scales,
          sampling_ratio=sampling_ratio,
          pooler_type="ROIAlignV2",
      )
  
      roialignv2_out = roialignv2_pooler(features, rois)
  
      roialignrotated_pooler = ROIPooler(
          output_size=pooler_resolution,
          scales=pooler_scales,
          sampling_ratio=sampling_ratio,
          pooler_type="ROIAlignRotated",
      )
  
      roialignrotated_out = roialignrotated_pooler(
          features, rois_rotated
      )
  
      self.assertTrue(
          torch.allclose(roialignv2_out, roialignrotated_out, atol=1e-4)
      )
  
file_path: detectron2/tests/modeling/test_roi_pooler.py
imports: import logging
  import unittest
  import torch
  from detectron2.modeling.poolers import ROIPooler
  from detectron2.structures import Boxes, RotatedBoxes
  from detectron2.utils.testing import random_boxes
label_desc: Use image node_id 1 for calling the TestROIPooler obj's underlying member method code with example usage: obj._test_roialignv2_roialignrotated_match(device) without return types