class_docstr: The quasi-dense roi embed head.
  
  Args:
      embed_channels (int): The input channel of embed features.
          Defaults to 256.
      softmax_temp (int): Softmax temperature. Defaults to -1.
      loss_track (dict): The loss function for tracking. Defaults to
          MultiPosCrossEntropyLoss.
      loss_track_aux (dict): The auxiliary loss function for tracking.
          Defaults to MarginL2Loss.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict]): Initialization config dict.
class_docstr_tok: ["The","quasi-dense","roi","embed","head",".","Args",":","embed_channels","(","int",")",":","The","input","channel","of","embed","features",".","Defaults","to","256.","softmax_temp","(","int",")",":","Softmax","temperature",".","Defaults","to","-1.","loss_track","(","dict",")",":","The","loss","function","for","tracking",".","Defaults","to","MultiPosCrossEntropyLoss",".","loss_track_aux","(","dict",")",":","The","auxiliary","loss","function","for","tracking",".","Defaults","to","MarginL2Loss",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",")",":","Initialization","config","dict","."]
docstr: Calculate the dist matrixes for loss measurement.
  
  Args:
      key_embeds (Tensor): Embeds of positive bboxes in sampling results
          of key image.
      ref_embeds (Tensor): Embeds of all bboxes in sampling results
          of the reference image.
      key_sampling_results (List[obj:SamplingResults]): Assign results of
          all images in a batch after sampling.
      ref_sampling_results (List[obj:SamplingResults]): Assign results of
          all reference images in a batch after sampling.
  
  Returns:
      Tuple[list[Tensor]]: Calculation results.
      Containing the following list of Tensors:
  
          - dists (list[Tensor]): Dot-product dists between
              key_embeds and ref_embeds, each tensor in list has
              shape (len(key_pos_bboxes), len(ref_bboxes)).
          - cos_dists (list[Tensor]): Cosine dists between
              key_embeds and ref_embeds, each tensor in list has
              shape (len(key_pos_bboxes), len(ref_bboxes)).
docstr_tok: ["Calculate","the","dist","matrixes","for","loss","measurement",".","Args",":","key_embeds","(","Tensor",")",":","Embeds","of","positive","bboxes","in","sampling","results","of","key","image",".","ref_embeds","(","Tensor",")",":","Embeds","of","all","bboxes","in","sampling","results","of","the","reference","image",".","key_sampling_results","(","List","[","obj",":","SamplingResults","]",")",":","Assign","results","of","all","images","in","a","batch","after","sampling",".","ref_sampling_results","(","List","[","obj",":","SamplingResults","]",")",":","Assign","results","of","all","reference","images","in","a","batch","after","sampling",".","Returns",":","Tuple","[","list","[","Tensor","]","]",":","Calculation","results",".","Containing","the","following","list","of","Tensors",":","-","dists","(","list","[","Tensor","]",")",":","Dot-product","dists","between","key_embeds","and","ref_embeds",",","each","tensor","in","list","has","shape","(","len","(","key_pos_bboxes",")",",","len","(","ref_bboxes",")",")",".","-","cos_dists","(","list","[","Tensor","]",")",":","Cosine","dists","between","key_embeds","and","ref_embeds",",","each","tensor","in","list","has","shape","(","len","(","key_pos_bboxes",")",",","len","(","ref_bboxes",")",")","."]
code: def match(
      self,
      key_embeds: Tensor,
      ref_embeds: Tensor,
      key_sampling_results: List[SamplingResult],
      ref_sampling_results: List[SamplingResult],
  ) -> Tuple[List[Tensor], List[Tensor]]:
      """Calculate the dist matrixes for loss measurement.
  
      Args:
          key_embeds (Tensor): Embeds of positive bboxes in sampling results
              of key image.
          ref_embeds (Tensor): Embeds of all bboxes in sampling results
              of the reference image.
          key_sampling_results (List[obj:SamplingResults]): Assign results of
              all images in a batch after sampling.
          ref_sampling_results (List[obj:SamplingResults]): Assign results of
              all reference images in a batch after sampling.
  
      Returns:
          Tuple[list[Tensor]]: Calculation results.
          Containing the following list of Tensors:
  
              - dists (list[Tensor]): Dot-product dists between
                  key_embeds and ref_embeds, each tensor in list has
                  shape (len(key_pos_bboxes), len(ref_bboxes)).
              - cos_dists (list[Tensor]): Cosine dists between
                  key_embeds and ref_embeds, each tensor in list has
                  shape (len(key_pos_bboxes), len(ref_bboxes)).
      """
  
      num_key_rois = [
          res.pos_bboxes.size(0) for res in key_sampling_results
      ]
      key_embeds = torch.split(key_embeds, num_key_rois)
      num_ref_rois = [
          res.bboxes.size(0) for res in ref_sampling_results
      ]
      ref_embeds = torch.split(ref_embeds, num_ref_rois)
  
      dists, cos_dists = [], []
      for key_embed, ref_embed in zip(key_embeds, ref_embeds):
          dist = embed_similarity(
              key_embed,
              ref_embed,
              method="dot_product",
              temperature=self.softmax_temp,
          )
          dists.append(dist)
          if self.loss_track_aux is not None:
              cos_dist = embed_similarity(
                  key_embed, ref_embed, method="cosine"
              )
              cos_dists.append(cos_dist)
          else:
              cos_dists.append(None)
      return dists, cos_dists
  
file_path: mmdetection/mmdet/models/tracking_heads/quasi_dense_embed_head.py
imports: from typing import List, Optional, Tuple
  import torch
  import torch.nn
  from mmcv.cnn import ConvModule
  from mmengine.model import BaseModule
  from torch import Tensor
  from torch.nn.modules.utils import _pair
  from mmdet.models.task_modules import SamplingResult
  from mmdet.registry import MODELS
  from ..task_modules.tracking import embed_similarity
label_desc: Use image node_id 5 for calling the QuasiDenseEmbedHead obj's underlying member method code with example usage: obj.match(key_embeds, ref_embeds, key_sampling_results, ref_sampling_results) and returns: dists,  cos_dists