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","."]
docstr: Computing the similarity scores between `x` and `ref_x`.
  
  Args:
      x (Tensor): of shape [N, C, H, W]. N is the number of key frame
          proposals.
      ref_x (Tensor): of shape [M, C, H, W]. M is the number of reference
          frame proposals.
      num_x_per_img (list[int]): The `x` contains proposals of
          multi-images. `num_x_per_img` denotes the number of proposals
          for each key image.
      num_x_per_ref_img (list[int]): The `ref_x` contains proposals of
          multi-images. `num_x_per_ref_img` denotes the number of
          proposals for each reference image.
  
  Returns:
      tuple[tuple[Tensor], tuple[Tensor]]: Each tuple of tensor denotes
      the embed features belonging to an image in a batch.
docstr_tok: ["Computing","the","similarity","scores","between","`","x","`","and","`","ref_x","`",".","Args",":","x","(","Tensor",")",":","of","shape","[","N",",","C",",","H",",","W","]",".","N","is","the","number","of","key","frame","proposals",".","ref_x","(","Tensor",")",":","of","shape","[","M",",","C",",","H",",","W","]",".","M","is","the","number","of","reference","frame","proposals",".","num_x_per_img","(","list","[","int","]",")",":","The","`","x","`","contains","proposals","of","multi-images",".","`","num_x_per_img","`","denotes","the","number","of","proposals","for","each","key","image",".","num_x_per_ref_img","(","list","[","int","]",")",":","The","`","ref_x","`","contains","proposals","of","multi-images",".","`","num_x_per_ref_img","`","denotes","the","number","of","proposals","for","each","reference","image",".","Returns",":","tuple","[","tuple","[","Tensor","]",",","tuple","[","Tensor","]","]",":","Each","tuple","of","tensor","denotes","the","embed","features","belonging","to","an","image","in","a","batch","."]
code: def forward(
      self,
      x: Tensor,
      ref_x: Tensor,
      num_x_per_img: List[int],
      num_x_per_ref_img: List[int],
  ) -> Tuple[Tuple[Tensor], Tuple[Tensor]]:
      """Computing the similarity scores between `x` and `ref_x`.
  
      Args:
          x (Tensor): of shape [N, C, H, W]. N is the number of key frame
              proposals.
          ref_x (Tensor): of shape [M, C, H, W]. M is the number of reference
              frame proposals.
          num_x_per_img (list[int]): The `x` contains proposals of
              multi-images. `num_x_per_img` denotes the number of proposals
              for each key image.
          num_x_per_ref_img (list[int]): The `ref_x` contains proposals of
              multi-images. `num_x_per_ref_img` denotes the number of
              proposals for each reference image.
  
      Returns:
          tuple[tuple[Tensor], tuple[Tensor]]: Each tuple of tensor denotes
          the embed features belonging to an image in a batch.
      """
      x_split = self.extract_feat(x, num_x_per_img)
      ref_x_split = self.extract_feat(ref_x, num_x_per_ref_img)
  
      return x_split, ref_x_split
  
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 5 for calling the RoIEmbedHead obj's underlying member method code with example usage: obj.forward(x, ref_x, num_x_per_img, num_x_per_ref_img) and returns: x_split,  ref_x_split