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: Args:
      x (list[Tensor]): list of multi-level img features.
      img_metas (list[dict]): list of image info dict where each dict
          has: 'img_shape', 'scale_factor', 'flip', and may also contain
          'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'.
          For details on the values of these keys see
          `mmdet/datasets/pipelines/formatting.py:Collect`.
      proposals (list[Tensors]): list of region proposals.
      gt_bboxes (list[Tensor]): Ground truth bboxes for each image with
          shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format.
      gt_labels (list[Tensor]): class indices corresponding to each box
      gt_bboxes_ignore (None | list[Tensor]): specify which bounding
          boxes can be ignored when computing the loss.
      gt_masks (None | Tensor) : true segmentation masks for each box
          used if the architecture supports a segmentation task.
  
  Returns:
      dict[str, Tensor]: a dictionary of loss components
docstr_tok: ["Args",":","x","(","list","[","Tensor","]",")",":","list","of","multi-level","img","features",".","img_metas","(","list","[","dict","]",")",":","list","of","image","info","dict","where","each","dict","has",":","'img_shape","'",",","'scale_factor","'",",","'flip","'",",","and","may","also","contain","'filename","'",",","'ori_shape","'",",","'pad_shape","'",",","and","'img_norm_cfg","'",".","For","details","on","the","values","of","these","keys","see","`","mmdet\/datasets\/pipelines\/formatting.py",":","Collect","`",".","proposals","(","list","[","Tensors","]",")",":","list","of","region","proposals",".","gt_bboxes","(","list","[","Tensor","]",")",":","Ground","truth","bboxes","for","each","image","with","shape","(","num_gts",",","4",")","in","[","tl_x",",","tl_y",",","br_x",",","br_y","]","format",".","gt_labels","(","list","[","Tensor","]",")",":","class","indices","corresponding","to","each","box","gt_bboxes_ignore","(","None","|","list","[","Tensor","]",")",":","specify","which","bounding","boxes","can","be","ignored","when","computing","the","loss",".","gt_masks","(","None","|","Tensor",")",":","true","segmentation","masks","for","each","box","used","if","the","architecture","supports","a","segmentation","task",".","Returns",":","dict","[","str",",","Tensor","]",":","a","dictionary","of","loss","components"]
code: def forward_train(
      self,
      x,
      img_metas,
      proposal_list,
      gt_bboxes,
      gt_labels,
      gt_bboxes_ignore=None,
      gt_masks=None,
  ):
      """
      Args:
          x (list[Tensor]): list of multi-level img features.
          img_metas (list[dict]): list of image info dict where each dict
              has: 'img_shape', 'scale_factor', 'flip', and may also contain
              'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'.
              For details on the values of these keys see
              `mmdet/datasets/pipelines/formatting.py:Collect`.
          proposals (list[Tensors]): list of region proposals.
          gt_bboxes (list[Tensor]): Ground truth bboxes for each image with
              shape (num_gts, 4) in [tl_x, tl_y, br_x, br_y] format.
          gt_labels (list[Tensor]): class indices corresponding to each box
          gt_bboxes_ignore (None | list[Tensor]): specify which bounding
              boxes can be ignored when computing the loss.
          gt_masks (None | Tensor) : true segmentation masks for each box
              used if the architecture supports a segmentation task.
  
      Returns:
          dict[str, Tensor]: a dictionary of loss components
      """
      # assign gts and sample proposals
      if self.with_bbox or self.with_mask:
          num_imgs = len(img_metas)
          if gt_bboxes_ignore is None:
              gt_bboxes_ignore = [None for _ in range(num_imgs)]
          sampling_results = []
          for i in range(num_imgs):
              assign_result = self.bbox_assigner.assign(
                  proposal_list[i],
                  gt_bboxes[i],
                  gt_bboxes_ignore[i],
                  gt_labels[i],
              )
              sampling_result = self.bbox_sampler.sample(
                  assign_result,
                  proposal_list[i],
                  gt_bboxes[i],
                  gt_labels[i],
                  feats=[lvl_feat[i][None] for lvl_feat in x],
              )
              sampling_results.append(sampling_result)
  
      losses = dict()
      # bbox head forward and loss
      if self.with_bbox:
          bbox_results = self._bbox_forward_train(
              x, sampling_results, gt_bboxes, gt_labels, img_metas
          )
          losses.update(bbox_results["loss_bbox"])
  
      # mask head forward and loss
      if self.with_mask:
          mask_results = self._mask_forward_train(
              x,
              sampling_results,
              bbox_results["bbox_feats"],
              gt_masks,
              img_metas,
          )
          losses.update(mask_results["loss_mask"])
  
      return losses
  
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 6 for calling the StandardRoIHead obj's underlying member method code with example usage: obj.forward_train(x, img_metas, proposal_list, gt_bboxes, gt_labels, gt_bboxes_ignore, gt_masks) and returns: losses