class_docstr: The roi embed head.
  
  This module is used in multi-object tracking methods, such as MaskTrack
  R-CNN.
  
  Args:
      num_convs (int): The number of convoluational layers to embed roi
          features. Defaults to 0.
      num_fcs (int): The number of fully connection layers to embed roi
          features. Defaults to 0.
      roi_feat_size (int|tuple(int)): The spatial size of roi features.
          Defaults to 7.
      in_channels (int): The input channel of roi features. Defaults to 256.
      conv_out_channels (int): The output channel of roi features after
          forwarding convoluational layers. Defaults to 256.
      with_avg_pool (bool): Whether use average pooling before passing roi
          features into fully connection layers. Defaults to False.
      fc_out_channels (int): The output channel of roi features after
          forwarding fully connection layers. Defaults to 1024.
      conv_cfg (dict): Config dict for convolution layer. Defaults to None,
          which means using conv2d.
      norm_cfg (dict): Config dict for normalization layer. Defaults to None.
      loss_match (dict): The loss function. Defaults to
          dict(type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)
      init_cfg (dict): Configuration of initialization. Defaults to None.
class_docstr_tok: ["The","roi","embed","head",".","This","module","is","used","in","multi-object","tracking","methods",",","such","as","MaskTrack","R-CNN",".","Args",":","num_convs","(","int",")",":","The","number","of","convoluational","layers","to","embed","roi","features",".","Defaults","to","0.","num_fcs","(","int",")",":","The","number","of","fully","connection","layers","to","embed","roi","features",".","Defaults","to","0.","roi_feat_size","(","int|tuple","(","int",")",")",":","The","spatial","size","of","roi","features",".","Defaults","to","7.","in_channels","(","int",")",":","The","input","channel","of","roi","features",".","Defaults","to","256.","conv_out_channels","(","int",")",":","The","output","channel","of","roi","features","after","forwarding","convoluational","layers",".","Defaults","to","256.","with_avg_pool","(","bool",")",":","Whether","use","average","pooling","before","passing","roi","features","into","fully","connection","layers",".","Defaults","to","False",".","fc_out_channels","(","int",")",":","The","output","channel","of","roi","features","after","forwarding","fully","connection","layers",".","Defaults","to","1024.","conv_cfg","(","dict",")",":","Config","dict","for","convolution","layer",".","Defaults","to","None",",","which","means","using","conv2d",".","norm_cfg","(","dict",")",":","Config","dict","for","normalization","layer",".","Defaults","to","None",".","loss_match","(","dict",")",":","The","loss","function",".","Defaults","to","dict","(","type='CrossEntropyLoss","'",",","use_sigmoid=False",",","loss_weight=1.0",")","init_cfg","(","dict",")",":","Configuration","of","initialization",".","Defaults","to","None","."]
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,
      loss_match: dict = dict(
          type="mmdet.CrossEntropyLoss",
          use_sigmoid=False,
          loss_weight=1.0,
      ),
      init_cfg: Optional[dict] = None,
      **kwargs,
  ):
      super(RoIEmbedHead, 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
      self.loss_match = MODELS.build(loss_match)
      self.fp16_enabled = False
  
      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)
  
imports: from collections import defaultdict
  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.losses import accuracy
  from mmdet.models.task_modules import SamplingResult
  from mmdet.models.task_modules.tracking import embed_similarity
  from mmdet.registry import MODELS
label_desc: Use image node_id 1 to create a new RoIEmbedHead object from inherited base classes: BaseModule with example: obj = RoIEmbedHead(num_convs, num_fcs, roi_feat_size, in_channels, conv_out_channels, with_avg_pool, fc_out_channels, conv_cfg, norm_cfg, loss_match, init_cfg)