class_docstr: RoIHead for `SCNet <https://arxiv.org/abs/2012.10150>`_.
  
  Args:
      num_stages (int): number of cascade stages.
      stage_loss_weights (list): loss weight of cascade stages.
      semantic_roi_extractor (dict): config to init semantic roi extractor.
      semantic_head (dict): config to init semantic head.
      feat_relay_head (dict): config to init feature_relay_head.
      glbctx_head (dict): config to init global context head.
docstr: Perform forward propagation of the mask head and predict detection
  results on the features of the upstream network.
  
  Args:
      x (tuple[Tensor]): Feature maps of all scale level.
      semantic_feat (Tensor): Semantic feature.
      glbctx_feat (Tensor): Global context feature.
      batch_img_metas (list[dict]): List of image information.
      results_list (list[:obj:`InstanceData`]): Detection results of
          each image.
      rescale (bool): If True, return boxes in original image space.
          Defaults to False.
  
  Returns:
      list[:obj:`InstanceData`]: Detection results of each image
      after the post process.
      Each item usually contains following keys.
  
          - scores (Tensor): Classification scores, has a shape
            (num_instance, )
          - labels (Tensor): Labels of bboxes, has a shape
            (num_instances, ).
          - bboxes (Tensor): Has a shape (num_instances, 4),
            the last dimension 4 arrange as (x1, y1, x2, y2).
          - masks (Tensor): Has a shape (num_instances, H, W).
docstr_tok: ["Perform","forward","propagation","of","the","mask","head","and","predict","detection","results","on","the","features","of","the","upstream","network",".","Args",":","x","(","tuple","[","Tensor","]",")",":","Feature","maps","of","all","scale","level",".","semantic_feat","(","Tensor",")",":","Semantic","feature",".","glbctx_feat","(","Tensor",")",":","Global","context","feature",".","batch_img_metas","(","list","[","dict","]",")",":","List","of","image","information",".","results_list","(","list","[",":","obj",":","`","InstanceData","`","]",")",":","Detection","results","of","each","image",".","rescale","(","bool",")",":","If","True",",","return","boxes","in","original","image","space",".","Defaults","to","False",".","Returns",":","list","[",":","obj",":","`","InstanceData","`","]",":","Detection","results","of","each","image","after","the","post","process",".","Each","item","usually","contains","following","keys",".","-","scores","(","Tensor",")",":","Classification","scores",",","has","a","shape","(","num_instance",",",")","-","labels","(","Tensor",")",":","Labels","of","bboxes",",","has","a","shape","(","num_instances",",",")",".","-","bboxes","(","Tensor",")",":","Has","a","shape","(","num_instances",",","4",")",",","the","last","dimension","4","arrange","as","(","x1",",","y1",",","x2",",","y2",")",".","-","masks","(","Tensor",")",":","Has","a","shape","(","num_instances",",","H",",","W",")","."]
code: def predict_mask(
      self,
      x: Tuple[Tensor],
      semantic_heat: Tensor,
      glbctx_feat: Tensor,
      batch_img_metas: List[dict],
      results_list: List[InstanceData],
      rescale: bool = False,
  ) -> List[InstanceData]:
      """Perform forward propagation of the mask head and predict detection
      results on the features of the upstream network.
  
      Args:
          x (tuple[Tensor]): Feature maps of all scale level.
          semantic_feat (Tensor): Semantic feature.
          glbctx_feat (Tensor): Global context feature.
          batch_img_metas (list[dict]): List of image information.
          results_list (list[:obj:`InstanceData`]): Detection results of
              each image.
          rescale (bool): If True, return boxes in original image space.
              Defaults to False.
  
      Returns:
          list[:obj:`InstanceData`]: Detection results of each image
          after the post process.
          Each item usually contains following keys.
  
              - scores (Tensor): Classification scores, has a shape
                (num_instance, )
              - labels (Tensor): Labels of bboxes, has a shape
                (num_instances, ).
              - bboxes (Tensor): Has a shape (num_instances, 4),
                the last dimension 4 arrange as (x1, y1, x2, y2).
              - masks (Tensor): Has a shape (num_instances, H, W).
      """
      bboxes = [res.bboxes for res in results_list]
      mask_rois = bbox2roi(bboxes)
      if mask_rois.shape[0] == 0:
          results_list = empty_instances(
              batch_img_metas=batch_img_metas,
              device=mask_rois.device,
              task_type="mask",
              instance_results=results_list,
              mask_thr_binary=self.test_cfg.mask_thr_binary,
          )
          return results_list
  
      bboxes_results = self._bbox_forward(
          stage=-1,
          x=x,
          rois=mask_rois,
          semantic_feat=semantic_heat,
          glbctx_feat=glbctx_feat,
      )
      relayed_feat = bboxes_results["relayed_feat"]
      relayed_feat = self.feat_relay_head(relayed_feat)
  
      mask_results = self._mask_forward(
          x=x,
          rois=mask_rois,
          semantic_feat=semantic_heat,
          glbctx_feat=glbctx_feat,
          relayed_feat=relayed_feat,
      )
      mask_preds = mask_results["mask_preds"]
  
      # split batch mask prediction back to each image
      num_bbox_per_img = tuple(len(_bbox) for _bbox in bboxes)
      mask_preds = mask_preds.split(num_bbox_per_img, 0)
  
      results_list = self.mask_head.predict_by_feat(
          mask_preds=mask_preds,
          results_list=results_list,
          batch_img_metas=batch_img_metas,
          rcnn_test_cfg=self.test_cfg,
          rescale=rescale,
      )
  
      return results_list
  
imports: from typing import List, Optional, Tuple
  import torch
  import torch.nn.functional
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import bbox2roi
  from mmdet.utils import ConfigType, InstanceList, OptConfigType
  from ..layers import adaptive_avg_pool2d
  from ..task_modules.samplers import SamplingResult
  from ..utils import empty_instances, unpack_gt_instances
  from .cascade_roi_head import CascadeRoIHead
label_desc: Use image node_id 16 for calling the SCNetRoIHead obj's underlying member method code with example usage: obj.predict_mask(x, semantic_heat, glbctx_feat, batch_img_metas, results_list, rescale) and returns: results_list, results_list