code: def test_quasi_dense_embed_head_loss(self):
      cfg = mmengine.Config(
          dict(
              num_convs=4,
              num_fcs=1,
              embed_channels=256,
              norm_cfg=dict(type="GN", num_groups=32),
              loss_track=dict(
                  type="MultiPosCrossEntropyLoss", loss_weight=0.25
              ),
              loss_track_aux=dict(
                  type="MarginL2Loss",
                  neg_pos_ub=3,
                  pos_margin=0,
                  neg_margin=0.1,
                  hard_mining=True,
                  loss_weight=1.0,
              ),
          )
      )
  
      embed_head = QuasiDenseEmbedHead(**cfg)
  
      key_feats = torch.rand(2, 256, 7, 7)
      ref_feats = key_feats
      rpn_results = InstanceData()
      rpn_results.labels = torch.LongTensor([1, 2])
      rpn_results.priors = torch.Tensor(
          [
              [23.6667, 23.8757, 238.6326, 151.8874],
              [23.6667, 23.8757, 238.6326, 151.8874],
          ]
      )
      rpn_results_list = [rpn_results]
  
      gt_instance = InstanceData()
      gt_instance.labels = torch.LongTensor([1, 2])
      gt_instance.bboxes = torch.Tensor(
          [
              [23.6667, 23.8757, 238.6326, 151.8874],
              [23.6667, 23.8757, 238.6326, 151.8874],
          ]
      )
      gt_instance.instances_id = torch.LongTensor([1, 2])
      batch_gt_instances = [gt_instance]
  
      sampling_results = _dummy_bbox_sampling(
          rpn_results_list, batch_gt_instances
      )
      gt_match_indices_list = [torch.Tensor([0, 1])]
      loss_track = embed_head.loss(
          key_feats,
          ref_feats,
          sampling_results,
          sampling_results,
          gt_match_indices_list,
      )
      assert loss_track["loss_track"] >= 0, "track loss should be zero"
      assert (
          loss_track["loss_track_aux"] > 0
      ), "aux loss should be non-zero"
  
file_path: mmdetection/tests/test_models/test_tracking_heads/test_quasi_dense_embed_head.py
imports: from unittest import TestCase
  import mmengine
  import torch
  from mmengine.structures import InstanceData
  from mmdet.models.tracking_heads import QuasiDenseEmbedHead
  from mmdet.registry import TASK_UTILS
label_desc: Use image node_id 1 for calling the TestQuasiDenseEmbedHead obj's underlying member method code with example usage: obj.test_quasi_dense_embed_head_loss() without return types