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","."]
code: def __init__(
      self,
      num_convs: int = 0,
      num_fcs: int = 0,
      roi_feat_size: int = 7,
      in_channels: int = 256,
      conv_out_channels: int = 256,
      with_avg_pool: bool = False,
      fc_out_channels: int = 1024,
      conv_cfg: Optional[dict] = None,
      norm_cfg: Optional[dict] = None,
      embed_channels: int = 256,
      softmax_temp: int = -1,
      loss_track: Optional[dict] = None,
      loss_track_aux: dict = dict(
          type="MarginL2Loss",
          sample_ratio=3,
          margin=0.3,
          loss_weight=1.0,
          hard_mining=True,
      ),
      init_cfg: dict = dict(
          type="Xavier",
          layer="Linear",
          distribution="uniform",
          bias=0,
          override=dict(
              type="Normal", name="fc_embed", mean=0, std=0.01, bias=0
          ),
      ),
  ):
      super(QuasiDenseEmbedHead, self).__init__(init_cfg=init_cfg)
      self.num_convs = num_convs
      self.num_fcs = num_fcs
      self.roi_feat_size = _pair(roi_feat_size)
      self.roi_feat_area = self.roi_feat_size[0] * self.roi_feat_size[1]
      self.in_channels = in_channels
      self.conv_out_channels = conv_out_channels
      self.with_avg_pool = with_avg_pool
      self.fc_out_channels = fc_out_channels
      self.conv_cfg = conv_cfg
      self.norm_cfg = norm_cfg
  
      if self.with_avg_pool:
          self.avg_pool = nn.AvgPool2d(self.roi_feat_size)
      # add convs and fcs
      (
          self.convs,
          self.fcs,
          self.last_layer_dim,
      ) = self._add_conv_fc_branch(
          self.num_convs, self.num_fcs, self.in_channels
      )
      self.relu = nn.ReLU(inplace=True)
  
      if loss_track is None:
          loss_track = dict(
              type="MultiPosCrossEntropyLoss", loss_weight=0.25
          )
  
      self.fc_embed = nn.Linear(self.last_layer_dim, embed_channels)
      self.softmax_temp = softmax_temp
      self.loss_track = MODELS.build(loss_track)
      if loss_track_aux is not None:
          self.loss_track_aux = MODELS.build(loss_track_aux)
      else:
          self.loss_track_aux = None
  
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 1 to create a new QuasiDenseEmbedHead object from inherited base classes: BaseModule with example: obj = QuasiDenseEmbedHead(num_convs, num_fcs, roi_feat_size, in_channels, conv_out_channels, with_avg_pool, fc_out_channels, conv_cfg, norm_cfg, embed_channels, softmax_temp, loss_track, loss_track_aux, init_cfg)