code: def test_mask_iou_head_predict_by_feat(self, device):
      if device == "cuda":
          if not torch.cuda.is_available():
              return unittest.skip("test requires GPU and torch+cuda")
  
      mask_iou_head = MaskIoUHead(num_classes=4)
      mask_iou_head.to(device=device)
  
      s = 128
      num_samples = 2
      num_classes = 4
      img_metas = {
          "img_shape": (s, s, 3),
          "scale_factor": (1, 1),
          "ori_shape": (s, s, 3),
      }
      results = InstanceData(metainfo=img_metas)
      results.bboxes = torch.rand((num_samples, 4)).to(device)
      results.scores = torch.rand((num_samples,)).to(device)
      results.labels = torch.randint(
          num_classes, (num_samples,), dtype=torch.long
      ).to(device)
  
      mask_feats = torch.rand((num_samples, 256, 14, 14)).to(device)
      mask_preds = torch.rand((num_samples, num_classes, 28, 28)).to(
          device
      )
      mask_iou_preds = mask_iou_head(
          mask_feats,
          mask_preds[range(results.labels.size(0)), results.labels],
      )
  
      mask_iou_head.predict_by_feat(
          mask_iou_preds=[mask_iou_preds], results_list=[results]
      )
  
file_path: mmdetection/tests/test_models/test_roi_heads/test_mask_heads/test_maskiou_head.py
imports: import unittest
  from unittest import TestCase
  import torch
  from mmengine.config import ConfigDict
  from mmengine.structures import InstanceData
  from parameterized import parameterized
  from mmdet.models.roi_heads.mask_heads import MaskIoUHead
  from mmdet.models.utils import unpack_gt_instances
  from mmdet.structures.mask import mask_target
  from mmdet.testing import demo_mm_inputs, demo_mm_proposals, demo_mm_sampling_results
label_desc: Use image node_id 2 for calling the TestMaskIoUHead obj's underlying member method code with example usage: obj.test_mask_iou_head_predict_by_feat(device) and returns: unittest