code: def test_hungarian(self):
      n_queries, n_targets, n_classes = 100, 15, 91
      logits = torch.rand(1, n_queries, n_classes + 1)
      boxes = torch.rand(1, n_queries, 4)
      tgt_labels = torch.randint(high=n_classes, size=(n_targets,))
      tgt_boxes = torch.rand(n_targets, 4)
      matcher = HungarianMatcher()
      targets = [{"labels": tgt_labels, "boxes": tgt_boxes}]
      indices_single = matcher(
          {"pred_logits": logits, "pred_boxes": boxes}, targets
      )
      indices_batched = matcher(
          {
              "pred_logits": logits.repeat(2, 1, 1),
              "pred_boxes": boxes.repeat(2, 1, 1),
          },
          targets * 2,
      )
      self.assertEqual(len(indices_single[0][0]), n_targets)
      self.assertEqual(len(indices_single[0][1]), n_targets)
      self.assertEqual(
          self.indices_torch2python(indices_single),
          self.indices_torch2python([indices_batched[0]]),
      )
      self.assertEqual(
          self.indices_torch2python(indices_single),
          self.indices_torch2python([indices_batched[1]]),
      )
  
      # test with empty targets
      tgt_labels_empty = torch.randint(high=n_classes, size=(0,))
      tgt_boxes_empty = torch.rand(0, 4)
      targets_empty = [
          {"labels": tgt_labels_empty, "boxes": tgt_boxes_empty}
      ]
      indices = matcher(
          {
              "pred_logits": logits.repeat(2, 1, 1),
              "pred_boxes": boxes.repeat(2, 1, 1),
          },
          targets + targets_empty,
      )
      self.assertEqual(len(indices[1][0]), 0)
      indices = matcher(
          {
              "pred_logits": logits.repeat(2, 1, 1),
              "pred_boxes": boxes.repeat(2, 1, 1),
          },
          targets_empty * 2,
      )
      self.assertEqual(len(indices[0][0]), 0)
  
imports: import io
  import unittest
  import torch
  from torch import nn, Tensor
  from typing import List
  from models.matcher import HungarianMatcher
  from models.position_encoding import PositionEmbeddingSine, PositionEmbeddingLearned
  from models.backbone import Backbone, Joiner, BackboneBase
  from util import box_ops
  from util.misc import nested_tensor_from_tensor_list
  from hubconf import detr_resnet50, detr_resnet50_panoptic
label_desc: Use image node_id 3 for calling the Tester obj's underlying member method code with example usage: obj.test_hungarian() without return types