class_docstr: Hybrid task cascade roi head including one bbox head and one mask head.
  
  https://arxiv.org/abs/1901.07518
class_docstr_tok: ["Hybrid","task","cascade","roi","head","including","one","bbox","head","and","one","mask","head",".","https",":","\/\/arxiv.org\/abs\/1901.07518"]
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,
      stage,
      x,
      sampling_results,
      gt_bboxes,
      gt_labels,
      rcnn_train_cfg,
      semantic_feat=None,
  ):
      """Run forward function and calculate loss for box head in training."""
      bbox_head = self.bbox_head[stage]
      rois = bbox2roi([res.bboxes for res in sampling_results])
      bbox_results = self._bbox_forward(
          stage, x, rois, semantic_feat=semantic_feat
      )
  
      bbox_targets = bbox_head.get_targets(
          sampling_results, gt_bboxes, gt_labels, rcnn_train_cfg
      )
      loss_bbox = bbox_head.loss(
          bbox_results["cls_score"],
          bbox_results["bbox_pred"],
          rois,
          *bbox_targets,
      )
  
      bbox_results.update(
          loss_bbox=loss_bbox,
          rois=rois,
          bbox_targets=bbox_targets,
      )
      return bbox_results
  
file_path: insightface/detection/scrfd/mmdet/models/roi_heads/htc_roi_head.py
imports: import torch
  import torch.nn.functional
  from mmdet.core import bbox2result, bbox2roi, bbox_mapping, merge_aug_bboxes, merge_aug_masks, multiclass_nms
  from ..builder import HEADS, build_head, build_roi_extractor
  from .cascade_roi_head import CascadeRoIHead
label_desc: Use image node_id 5 for calling the HybridTaskCascadeRoIHead obj's underlying member method code with example usage: obj._bbox_forward_train(stage, x, sampling_results, gt_bboxes, gt_labels, rcnn_train_cfg, semantic_feat) and returns: bbox_results