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 track loss and the auxiliary track loss.
  
  Args:
      key_track_feats (Tensor): Embeds of positive bboxes in sampling
          results of key image.
      ref_track_feats (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.
      gt_match_indices_list (list(Tensor)): Mapping from instances_ids
          from key image to reference image of the same tracklet in a
          pair of images.
  
  Returns:
      Dict [str: Tensor]: Calculation results.
      Containing the following list of Tensors:
  
          - loss_track (Tensor): Results of loss_track function.
          - loss_track_aux (Tensor): Results of loss_track_aux function.
docstr_tok: ["Calculate","the","track","loss","and","the","auxiliary","track","loss",".","Args",":","key_track_feats","(","Tensor",")",":","Embeds","of","positive","bboxes","in","sampling","results","of","key","image",".","ref_track_feats","(","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",".","gt_match_indices_list","(","list","(","Tensor",")",")",":","Mapping","from","instances_ids","from","key","image","to","reference","image","of","the","same","tracklet","in","a","pair","of","images",".","Returns",":","Dict","[","str",":","Tensor","]",":","Calculation","results",".","Containing","the","following","list","of","Tensors",":","-","loss_track","(","Tensor",")",":","Results","of","loss_track","function",".","-","loss_track_aux","(","Tensor",")",":","Results","of","loss_track_aux","function","."]
code: def loss_by_feat(
      self,
      key_track_feats: Tensor,
      ref_track_feats: Tensor,
      key_sampling_results: List[SamplingResult],
      ref_sampling_results: List[SamplingResult],
      gt_match_indices_list: List[Tensor],
  ) -> dict:
      """Calculate the track loss and the auxiliary track loss.
  
      Args:
          key_track_feats (Tensor): Embeds of positive bboxes in sampling
              results of key image.
          ref_track_feats (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.
          gt_match_indices_list (list(Tensor)): Mapping from instances_ids
              from key image to reference image of the same tracklet in a
              pair of images.
  
      Returns:
          Dict [str: Tensor]: Calculation results.
          Containing the following list of Tensors:
  
              - loss_track (Tensor): Results of loss_track function.
              - loss_track_aux (Tensor): Results of loss_track_aux function.
      """
      dists, cos_dists = self.match(
          key_track_feats,
          ref_track_feats,
          key_sampling_results,
          ref_sampling_results,
      )
      targets, weights = self.get_targets(
          gt_match_indices_list,
          key_sampling_results,
          ref_sampling_results,
      )
      losses = dict()
  
      loss_track = 0.0
      loss_track_aux = 0.0
      for _dists, _cos_dists, _targets, _weights in zip(
          dists, cos_dists, targets, weights
      ):
          loss_track += self.loss_track(
              _dists, _targets, _weights, avg_factor=_weights.sum()
          )
          if self.loss_track_aux is not None:
              loss_track_aux += self.loss_track_aux(
                  _cos_dists, _targets
              )
      losses["loss_track"] = loss_track / len(dists)
  
      if self.loss_track_aux is not None:
          losses["loss_track_aux"] = loss_track_aux / len(dists)
  
      return losses
  
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 7 for calling the QuasiDenseEmbedHead obj's underlying member method code with example usage: obj.loss_by_feat(key_track_feats, ref_track_feats, key_sampling_results, ref_sampling_results, gt_match_indices_list) and returns: losses