class_docstr: CondInst mask head used in https://arxiv.org/abs/1904.02689.
  
  This head outputs the mask for CondInst.
  
  Args:
      mask_feature_head (dict): Config of CondInstMaskFeatHead.
      num_layers (int): Number of dynamic conv layers.
      feat_channels (int): Number of channels in the dynamic conv.
      mask_out_stride (int): The stride of the mask feat.
      size_of_interest (int): The size of the region used in rel coord.
      max_masks_to_train (int): Maximum number of masks to train for
          each image.
      loss_segm (:obj:`ConfigDict` or dict, optional): Config of
          segmentation loss.
      train_cfg (:obj:`ConfigDict` or dict, optional): Training config
          of head.
      test_cfg (:obj:`ConfigDict` or dict, optional): Testing config of
          head.
class_docstr_tok: ["CondInst","mask","head","used","in","https",":","\/\/arxiv.org\/abs\/1904.02689",".","This","head","outputs","the","mask","for","CondInst",".","Args",":","mask_feature_head","(","dict",")",":","Config","of","CondInstMaskFeatHead",".","num_layers","(","int",")",":","Number","of","dynamic","conv","layers",".","feat_channels","(","int",")",":","Number","of","channels","in","the","dynamic","conv",".","mask_out_stride","(","int",")",":","The","stride","of","the","mask","feat",".","size_of_interest","(","int",")",":","The","size","of","the","region","used","in","rel","coord",".","max_masks_to_train","(","int",")",":","Maximum","number","of","masks","to","train","for","each","image",".","loss_segm","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","of","segmentation","loss",".","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Training","config","of","head",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Testing","config","of","head","."]
docstr: Transform a single image's features extracted from the head into
  mask results.
  
  Args:
      mask_preds (Tensor): Predicted prototypes, has shape [H, W, N].
      img_meta (dict): Meta information of each image, e.g.,
          image size, scaling factor, etc.
      rescale (bool): If rescale is False, then returned masks will
          fit the scale of imgs[0].
      cfg (dict, optional): Config used in test phase.
          Defaults to None.
  
  Returns:
      :obj:`InstanceData`: Processed results of single image.
       it usually contains following keys.
  
          - scores (Tensor): Classification scores, has shape
            (num_instance,).
          - labels (Tensor): Has shape (num_instances,).
          - masks (Tensor): Processed mask results, has
            shape (num_instances, h, w).
docstr_tok: ["Transform","a","single","image","'s","features","extracted","from","the","head","into","mask","results",".","Args",":","mask_preds","(","Tensor",")",":","Predicted","prototypes",",","has","shape","[","H",",","W",",","N","]",".","img_meta","(","dict",")",":","Meta","information","of","each","image",",","e.g.",",","image","size",",","scaling","factor",",","etc",".","rescale","(","bool",")",":","If","rescale","is","False",",","then","returned","masks","will","fit","the","scale","of","imgs","[","0","]",".","cfg","(","dict",",","optional",")",":","Config","used","in","test","phase",".","Defaults","to","None",".","Returns",":",":","obj",":","`","InstanceData","`",":","Processed","results","of","single","image",".","it","usually","contains","following","keys",".","-","scores","(","Tensor",")",":","Classification","scores",",","has","shape","(","num_instance",",",")",".","-","labels","(","Tensor",")",":","Has","shape","(","num_instances",",",")",".","-","masks","(","Tensor",")",":","Processed","mask","results",",","has","shape","(","num_instances",",","h",",","w",")","."]
code: def _predict_by_feat_single(
      self,
      mask_preds: Tensor,
      bboxes: Tensor,
      img_meta: dict,
      rescale: bool,
      cfg: OptConfigType = None,
  ):
      """Transform a single image's features extracted from the head into
      mask results.
  
      Args:
          mask_preds (Tensor): Predicted prototypes, has shape [H, W, N].
          img_meta (dict): Meta information of each image, e.g.,
              image size, scaling factor, etc.
          rescale (bool): If rescale is False, then returned masks will
              fit the scale of imgs[0].
          cfg (dict, optional): Config used in test phase.
              Defaults to None.
  
      Returns:
          :obj:`InstanceData`: Processed results of single image.
           it usually contains following keys.
  
              - scores (Tensor): Classification scores, has shape
                (num_instance,).
              - labels (Tensor): Has shape (num_instances,).
              - masks (Tensor): Processed mask results, has
                shape (num_instances, h, w).
      """
      cfg = self.test_cfg if cfg is None else cfg
      scale_factor = bboxes.new_tensor(img_meta["scale_factor"]).repeat(
          (1, 2)
      )
      img_h, img_w = img_meta["img_shape"][:2]
      ori_h, ori_w = img_meta["ori_shape"][:2]
  
      mask_preds = mask_preds.sigmoid().unsqueeze(0)
      mask_preds = aligned_bilinear(mask_preds, self.mask_out_stride)
      mask_preds = mask_preds[:, :, :img_h, :img_w]
      if rescale:  # in-placed rescale the bboxes
          scale_factor = bboxes.new_tensor(
              img_meta["scale_factor"]
          ).repeat((1, 2))
          bboxes /= scale_factor
  
          masks = (
              F.interpolate(
                  mask_preds,
                  (ori_h, ori_w),
                  mode="bilinear",
                  align_corners=False,
              ).squeeze(0)
              > cfg.mask_thr
          )
      else:
          masks = mask_preds.squeeze(0) > cfg.mask_thr
  
      return masks
  
imports: import copy
  from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, Scale
  from mmengine.config import ConfigDict
  from mmengine.model import BaseModule, kaiming_init
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures.bbox import cat_boxes
  from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptConfigType, OptInstanceList, reduce_mean
  from ..task_modules.prior_generators import MlvlPointGenerator
  from ..utils import aligned_bilinear, filter_scores_and_topk, multi_apply, relative_coordinate_maps, select_single_mlvl
  from ..utils.misc import empty_instances
  from .base_mask_head import BaseMaskHead
  from .fcos_head import FCOSHead
label_desc: Use image node_id 10 for calling the CondInstMaskHead obj's underlying member method code with example usage: obj._predict_by_feat_single(mask_preds, bboxes, img_meta, rescale, cfg) and returns: masks