code: def test_topk_hungarian_match_assigner(self):
      num_classes = 80
      topk = 4
  
      pred_class_scores = torch.rand((10, num_classes))
      pred_bboxes = torch.randn((10, 4))
  
      assigner = TopkHungarianAssigner(topk=topk)
  
      # test no gt bboxes
      gt_bboxes = torch.empty((0, 4))
      gt_labels = torch.LongTensor([])
      img_meta = dict(img_shape=(10, 8))
  
      assign_result = assigner.assign(
          pred_class_scores, pred_bboxes, gt_bboxes, gt_labels, img_meta
      )
  
      self.assertTrue(torch.all(assign_result.gt_inds == 0))
      self.assertTrue(torch.all(assign_result.labels == -1))
  
      # test with gt bboxes
      gt_bboxes = torch.FloatTensor([[0, 0, 5, 7], [3, 5, 7, 8]])
      gt_labels = torch.LongTensor([1, 20])
      assign_result = assigner.assign(
          pred_class_scores, pred_bboxes, gt_bboxes, gt_labels, img_meta
      )
  
      self.assertTrue(torch.all(assign_result.gt_inds > -1))
      self.assertEqual(
          (assign_result.gt_inds > 0).sum(), gt_bboxes.size(0) * topk
      )
      self.assertEqual(
          (assign_result.labels > -1).sum(), gt_bboxes.size(0) * topk
      )
  
file_path: mmdetection/tests/test_models/test_task_modules/test_assigners/test_topk_hungarian_assigner.py
imports: from unittest import TestCase
  import torch
  from mmengine import ConfigDict
  from mmdet.models.task_modules.assigners import TopkHungarianAssigner
label_desc: Use image node_id 2 for calling the TestTopkHungarianAssigner obj's underlying member method code with example usage: obj.test_topk_hungarian_match_assigner() without return types