class_docstr: `PointRend <https://arxiv.org/abs/1912.08193>`_.
class_docstr_tok: ["`","PointRend","<","https",":","\/\/arxiv.org\/abs\/1912.08193",">","`","_","."]
docstr: Run forward function and calculate loss for point head in
  training.
docstr_tok: ["Run","forward","function","and","calculate","loss","for","point","head","in","training","."]
code: def _mask_point_loss(
      self,
      x: Tuple[Tensor],
      sampling_results: List[SamplingResult],
      mask_preds: Tensor,
      batch_gt_instances: InstanceList,
  ) -> dict:
      """Run forward function and calculate loss for point head in
      training."""
      pos_labels = torch.cat(
          [res.pos_gt_labels for res in sampling_results]
      )
      rel_roi_points = self.point_head.get_roi_rel_points_train(
          mask_preds, pos_labels, cfg=self.train_cfg
      )
      rois = bbox2roi([res.pos_bboxes for res in sampling_results])
  
      fine_grained_point_feats = self._get_fine_grained_point_feats(
          x, rois, rel_roi_points
      )
      coarse_point_feats = point_sample(mask_preds, rel_roi_points)
      mask_point_pred = self.point_head(
          fine_grained_point_feats, coarse_point_feats
      )
  
      loss_and_target = self.point_head.loss_and_target(
          point_pred=mask_point_pred,
          rel_roi_points=rel_roi_points,
          sampling_results=sampling_results,
          batch_gt_instances=batch_gt_instances,
          cfg=self.train_cfg,
      )
  
      return loss_and_target
  
file_path: mmdetection/mmdet/models/roi_heads/point_rend_roi_head.py
imports: from typing import List, Tuple
  import torch
  import torch.nn.functional
  from mmcv.ops import point_sample, rel_roi_point_to_rel_img_point
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures.bbox import bbox2roi
  from mmdet.utils import ConfigType, InstanceList
  from ..task_modules.samplers import SamplingResult
  from ..utils import empty_instances
  from .standard_roi_head import StandardRoIHead
label_desc: Use image node_id 4 for calling the PointRendRoIHead obj's underlying member method code with example usage: obj._mask_point_loss(x, sampling_results, mask_preds, batch_gt_instances) and returns: loss_and_target