docstr: Calculate the ground truth for all samples in a batch according to
  the sampling_results.
  
  Args:
      sampling_results (List[obj:SamplingResult]): Assign results of
          all images in a batch after sampling.
      batch_gt_instances (list[:obj:`InstanceData`]): Batch of
          gt_instance. It usually includes ``bboxes``, ``labels``, and
          ``masks`` attributes.
      rcnn_train_cfg (obj:ConfigDict): `train_cfg` of RCNN.
  
  Returns:
      Tensor: Mask target of each positive proposals in the image.
docstr_tok: ["Calculate","the","ground","truth","for","all","samples","in","a","batch","according","to","the","sampling_results",".","Args",":","sampling_results","(","List","[","obj",":","SamplingResult","]",")",":","Assign","results","of","all","images","in","a","batch","after","sampling",".","batch_gt_instances","(","list","[",":","obj",":","`","InstanceData","`","]",")",":","Batch","of","gt_instance",".","It","usually","includes","``","bboxes","``",",","``","labels","``",",","and","``","masks","``","attributes",".","rcnn_train_cfg","(","obj",":","ConfigDict",")",":","`","train_cfg","`","of","RCNN",".","Returns",":","Tensor",":","Mask","target","of","each","positive","proposals","in","the","image","."]
code: def get_targets(
      self,
      sampling_results: List[SamplingResult],
      batch_gt_instances: InstanceList,
      rcnn_train_cfg: ConfigDict,
  ) -> Tensor:
      """Calculate the ground truth for all samples in a batch according to
      the sampling_results.
  
      Args:
          sampling_results (List[obj:SamplingResult]): Assign results of
              all images in a batch after sampling.
          batch_gt_instances (list[:obj:`InstanceData`]): Batch of
              gt_instance. It usually includes ``bboxes``, ``labels``, and
              ``masks`` attributes.
          rcnn_train_cfg (obj:ConfigDict): `train_cfg` of RCNN.
  
      Returns:
          Tensor: Mask target of each positive proposals in the image.
      """
      pos_proposals = [res.pos_priors for res in sampling_results]
      pos_assigned_gt_inds = [
          res.pos_assigned_gt_inds for res in sampling_results
      ]
      gt_masks = [res.masks for res in batch_gt_instances]
      mask_targets = mask_target(
          pos_proposals, pos_assigned_gt_inds, gt_masks, rcnn_train_cfg
      )
      return mask_targets
  
imports: from typing import List, Tuple
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, build_conv_layer, build_upsample_layer
  from mmcv.ops.carafe import CARAFEPack
  from mmengine.config import ConfigDict
  from mmengine.model import BaseModule, ModuleList
  from mmengine.structures import InstanceData
  from torch import Tensor
  from torch.nn.modules.utils import _pair
  from mmdet.models.task_modules.samplers import SamplingResult
  from mmdet.models.utils import empty_instances
  from mmdet.registry import MODELS
  from mmdet.structures.mask import mask_target
  from mmdet.utils import ConfigType, InstanceList, OptConfigType, OptMultiConfig
label_desc: Use image node_id 4 for calling the FCNMaskHead obj's underlying member method code with example usage: obj.get_targets(sampling_results, batch_gt_instances, rcnn_train_cfg) and returns: mask_targets