code: def test_mask_match_cost(self):
      gt_instances = InstanceData()
      gt_instances.masks = torch.randint(0, 2, (2, 10, 10)).long()
      gt_instances.labels = torch.LongTensor([1, 20])
  
      pred_instances = InstanceData()
      pred_instances.masks = torch.rand((4, 10, 10))
      pred_instances.scores = torch.rand((4, 25))
      img_meta = dict(img_shape=(10, 10))
  
      # test DiceCost
      assigner = HungarianAssigner(dict(type="DiceCost"))
      assign_result = assigner.assign(
          pred_instances, gt_instances, img_meta=img_meta
      )
      self.assertTrue(torch.all(assign_result.gt_inds > -1))
      self.assertEqual(
          (assign_result.gt_inds > 0).sum(), gt_instances.masks.size(0)
      )
      self.assertEqual(
          (assign_result.labels > -1).sum(), gt_instances.masks.size(0)
      )
  
      # test CrossEntropyLossCost
      assigner = HungarianAssigner(dict(type="CrossEntropyLossCost"))
      assign_result = assigner.assign(
          pred_instances, gt_instances, img_meta=img_meta
      )
      self.assertTrue(torch.all(assign_result.gt_inds > -1))
      self.assertEqual(
          (assign_result.gt_inds > 0).sum(), gt_instances.masks.size(0)
      )
      self.assertEqual(
          (assign_result.labels > -1).sum(), gt_instances.masks.size(0)
      )
  
      # test FocalLossCost
      assigner = HungarianAssigner(
          dict(type="FocalLossCost", binary_input=True)
      )
      assign_result = assigner.assign(
          pred_instances, gt_instances, img_meta=img_meta
      )
      self.assertTrue(torch.all(assign_result.gt_inds > -1))
      self.assertEqual(
          (assign_result.gt_inds > 0).sum(), gt_instances.masks.size(0)
      )
      self.assertEqual(
          (assign_result.labels > -1).sum(), gt_instances.masks.size(0)
      )
  
file_path: mmdetection/tests/test_models/test_task_modules/test_assigners/test_hungarian_assigner.py
imports: from unittest import TestCase
  import torch
  from mmengine import ConfigDict
  from mmengine.structures import InstanceData
  from mmdet.models.task_modules.assigners import HungarianAssigner
label_desc: Use image node_id 5 for calling the TestHungarianAssigner obj's underlying member method code with example usage: obj.test_mask_match_cost() without return types