docstr: Args:
      features (dict[str, Tensor]): a dict of image-level features
      instances (list[Instances]): proposals in training; detected
          instances in inference
docstr_tok: ["Args",":","features","(","dict","[","str",",","Tensor","]",")",":","a","dict","of","image-level","features","instances","(","list","[","Instances","]",")",":","proposals","in","training",";","detected","instances","in","inference"]
code: def forward(self, features, instances):
      """
      Args:
          features (dict[str, Tensor]): a dict of image-level features
          instances (list[Instances]): proposals in training; detected
              instances in inference
      """
      if self.training:
          proposal_boxes = [x.proposal_boxes for x in instances]
          coarse_mask = self.coarse_head(
              self._roi_pooler(features, proposal_boxes)
          )
          losses = {"loss_mask": mask_rcnn_loss(coarse_mask, instances)}
          if not self.mask_point_on:
              return losses
  
          point_coords, point_labels = self._sample_train_points(
              coarse_mask, instances
          )
          point_fine_grained_features = self._point_pooler(
              features, proposal_boxes, point_coords
          )
          point_logits = self._get_point_logits(
              point_fine_grained_features, point_coords, coarse_mask
          )
          losses["loss_mask_point"] = roi_mask_point_loss(
              point_logits, instances, point_labels
          )
          return losses
      else:
          pred_boxes = [x.pred_boxes for x in instances]
          coarse_mask = self.coarse_head(
              self._roi_pooler(features, pred_boxes)
          )
          return self._subdivision_inference(
              features, coarse_mask, instances
          )
  
imports: import logging
  import math
  import numpy
  from typing import Dict, List, Tuple
  import fvcore.nn.weight_init
  import torch
  from torch import Tensor, nn
  from torch.nn import functional
  from detectron2.config import configurable
  from detectron2.layers import Conv2d, ShapeSpec, cat, interpolate
  from detectron2.modeling import ROI_MASK_HEAD_REGISTRY
  from detectron2.modeling.roi_heads.mask_head import mask_rcnn_inference, mask_rcnn_loss
  from detectron2.structures import Boxes
  from .point_features import generate_regular_grid_point_coords, get_point_coords_wrt_image, get_uncertain_point_coords_on_grid, get_uncertain_point_coords_with_randomness, point_sample, point_sample_fine_grained_features, sample_point_labels
  from .point_head import build_point_head, roi_mask_point_loss
label_desc: Use image node_id 4 for calling the PointRendMaskHead obj's underlying member method code with example usage: obj.forward(features, instances) and returns: losses, self, losses