class_docstr: YOLACT segmentation head used in https://arxiv.org/abs/1904.02689.
  
  Apply a semantic segmentation loss on feature space using layers that are
  only evaluated during training to increase performance with no speed
  penalty.
  
  Args:
      in_channels (int): Number of channels in the input feature map.
      num_classes (int): Number of categories excluding the background
          category.
      loss_segm (dict): Config of semantic segmentation loss.
docstr: Compute semantic segmentation targets for each image.
  
  Args:
      segm_pred (Tensor): Predicted semantic segmentation map
          with shape (num_classes, H, W).
      gt_masks (Tensor): Ground truth masks for each image with
          the same shape of the input image.
      gt_labels (Tensor): Class indices corresponding to each box.
  
  Returns:
      Tensor: Semantic segmentation targets with shape
          (num_classes, H, W).
docstr_tok: ["Compute","semantic","segmentation","targets","for","each","image",".","Args",":","segm_pred","(","Tensor",")",":","Predicted","semantic","segmentation","map","with","shape","(","num_classes",",","H",",","W",")",".","gt_masks","(","Tensor",")",":","Ground","truth","masks","for","each","image","with","the","same","shape","of","the","input","image",".","gt_labels","(","Tensor",")",":","Class","indices","corresponding","to","each","box",".","Returns",":","Tensor",":","Semantic","segmentation","targets","with","shape","(","num_classes",",","H",",","W",")","."]
code: def get_targets(self, segm_pred, gt_masks, gt_labels):
      """Compute semantic segmentation targets for each image.
  
      Args:
          segm_pred (Tensor): Predicted semantic segmentation map
              with shape (num_classes, H, W).
          gt_masks (Tensor): Ground truth masks for each image with
              the same shape of the input image.
          gt_labels (Tensor): Class indices corresponding to each box.
  
      Returns:
          Tensor: Semantic segmentation targets with shape
              (num_classes, H, W).
      """
      if gt_masks.size(0) == 0:
          return None
      num_classes, mask_h, mask_w = segm_pred.size()
      with torch.no_grad():
          downsampled_masks = F.interpolate(
              gt_masks.unsqueeze(0),
              (mask_h, mask_w),
              mode="bilinear",
              align_corners=False,
          ).squeeze(0)
          downsampled_masks = downsampled_masks.gt(0.5).float()
          segm_targets = torch.zeros_like(
              segm_pred, requires_grad=False
          )
          for obj_idx in range(downsampled_masks.size(0)):
              segm_targets[gt_labels[obj_idx] - 1] = torch.max(
                  segm_targets[gt_labels[obj_idx] - 1],
                  downsampled_masks[obj_idx],
              )
          return segm_targets
  
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, xavier_init
  from mmcv.runner import force_fp32
  from mmdet.core import build_sampler, fast_nms, images_to_levels, multi_apply
  from ..builder import HEADS, build_loss
  from .anchor_head import AnchorHead
label_desc: Use image node_id 6 for calling the YOLACTSegmHead obj's underlying member method code with example usage: obj.get_targets(segm_pred, gt_masks, gt_labels) and returns: None, segm_targets