class_docstr: Simplest base roi head including one bbox head and one mask head.
class_docstr_tok: ["Simplest","base","roi","head","including","one","bbox","head","and","one","mask","head","."]
docstr: Run forward function and calculate loss for box head in training.
docstr_tok: ["Run","forward","function","and","calculate","loss","for","box","head","in","training","."]
code: def _bbox_forward_train(
      self, x, sampling_results, gt_bboxes, gt_labels, img_metas
  ):
      """Run forward function and calculate loss for box head in training."""
      rois = bbox2roi([res.bboxes for res in sampling_results])
      bbox_results = self._bbox_forward(x, rois)
  
      bbox_targets = self.bbox_head.get_targets(
          sampling_results, gt_bboxes, gt_labels, self.train_cfg
      )
      loss_bbox = self.bbox_head.loss(
          bbox_results["cls_score"],
          bbox_results["bbox_pred"],
          rois,
          *bbox_targets,
      )
  
      bbox_results.update(loss_bbox=loss_bbox)
      return bbox_results
  
imports: import torch
  from mmdet.core import bbox2result, bbox2roi, build_assigner, build_sampler
  from ..builder import HEADS, build_head, build_roi_extractor
  from .base_roi_head import BaseRoIHead
  from .test_mixins import BBoxTestMixin, MaskTestMixin
label_desc: Use image node_id 8 for calling the StandardRoIHead obj's underlying member method code with example usage: obj._bbox_forward_train(x, sampling_results, gt_bboxes, gt_labels, img_metas) and returns: bbox_results