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 batch of output features extracted from the head into
  mask results.
  
  Args:
      mask_preds (list[Tensor]): Predicted prototypes with shape
          (num_classes, H, W).
      results_list (List[:obj:``InstanceData``]): BBoxHead results.
      batch_img_metas (list[dict]): Meta information of all images.
      rescale (bool, optional): Whether to rescale the results.
          Defaults to False.
  
  Returns:
      list[:obj:`InstanceData`]: Processed results of multiple
      images.Each :obj:`InstanceData` 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","batch","of","output","features","extracted","from","the","head","into","mask","results",".","Args",":","mask_preds","(","list","[","Tensor","]",")",":","Predicted","prototypes","with","shape","(","num_classes",",","H",",","W",")",".","results_list","(","List","[",":","obj",":","``","InstanceData","``","]",")",":","BBoxHead","results",".","batch_img_metas","(","list","[","dict","]",")",":","Meta","information","of","all","images",".","rescale","(","bool",",","optional",")",":","Whether","to","rescale","the","results",".","Defaults","to","False",".","Returns",":","list","[",":","obj",":","`","InstanceData","`","]",":","Processed","results","of","multiple","images.Each",":","obj",":","`","InstanceData","`","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(
      self,
      mask_preds: List[Tensor],
      results_list: InstanceList,
      batch_img_metas: List[dict],
      rescale: bool = True,
      **kwargs,
  ) -> InstanceList:
      """Transform a batch of output features extracted from the head into
      mask results.
  
      Args:
          mask_preds (list[Tensor]): Predicted prototypes with shape
              (num_classes, H, W).
          results_list (List[:obj:``InstanceData``]): BBoxHead results.
          batch_img_metas (list[dict]): Meta information of all images.
          rescale (bool, optional): Whether to rescale the results.
              Defaults to False.
  
      Returns:
          list[:obj:`InstanceData`]: Processed results of multiple
          images.Each :obj:`InstanceData` 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).
      """
      assert (
          len(mask_preds) == len(results_list) == len(batch_img_metas)
      )
  
      for img_id in range(len(batch_img_metas)):
          img_meta = batch_img_metas[img_id]
          results = results_list[img_id]
          bboxes = results.bboxes
          mask_pred = mask_preds[img_id]
          if bboxes.shape[0] == 0 or mask_pred.shape[0] == 0:
              results_list[img_id] = empty_instances(
                  [img_meta],
                  bboxes.device,
                  task_type="mask",
                  instance_results=[results],
              )[0]
          else:
              im_mask = self._predict_by_feat_single(
                  mask_preds=mask_pred,
                  bboxes=bboxes,
                  img_meta=img_meta,
                  rescale=rescale,
              )
              results.masks = im_mask
      return results_list
  
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 9 for calling the CondInstMaskHead obj's underlying member method code with example usage: obj.predict_by_feat(mask_preds, results_list, batch_img_metas, rescale) and returns: results_list