class_docstr: Two linear layers for predicting Fast R-CNN outputs:
  
  1. proposal-to-detection box regression deltas
  2. classification scores
class_docstr_tok: ["Two","linear","layers","for","predicting","Fast","R-CNN","outputs",":","1.","proposal-to-detection","box","regression","deltas","2.","classification","scores"]
docstr: Args:
      proposal_boxes/gt_boxes are tensors with the same shape (R, 4 or 5).
      pred_deltas has shape (R, 4 or 5), or (R, num_classes * (4 or 5)).
      gt_classes is a long tensor of shape R, the gt class label of each proposal.
      R shall be the number of proposals.
docstr_tok: ["Args",":","proposal_boxes\/gt_boxes","are","tensors","with","the","same","shape","(","R",",","4","or","5",")",".","pred_deltas","has","shape","(","R",",","4","or","5",")",",","or","(","R",",","num_classes","*","(","4","or","5",")",")",".","gt_classes","is","a","long","tensor","of","shape","R",",","the","gt","class","label","of","each","proposal",".","R","shall","be","the","number","of","proposals","."]
code: def box_reg_loss(
      self, proposal_boxes, gt_boxes, pred_deltas, gt_classes
  ):
      """
      Args:
          proposal_boxes/gt_boxes are tensors with the same shape (R, 4 or 5).
          pred_deltas has shape (R, 4 or 5), or (R, num_classes * (4 or 5)).
          gt_classes is a long tensor of shape R, the gt class label of each proposal.
          R shall be the number of proposals.
      """
      box_dim = proposal_boxes.shape[1]  # 4 or 5
      # Regression loss is only computed for foreground proposals (those matched to a GT)
      fg_inds = nonzero_tuple(
          (gt_classes >= 0) & (gt_classes < self.num_classes)
      )[0]
      if pred_deltas.shape[1] == box_dim:  # cls-agnostic regression
          fg_pred_deltas = pred_deltas[fg_inds]
      else:
          fg_pred_deltas = pred_deltas.view(
              -1, self.num_classes, box_dim
          )[fg_inds, gt_classes[fg_inds]]
  
      loss_box_reg = _dense_box_regression_loss(
          [proposal_boxes[fg_inds]],
          self.box2box_transform,
          [fg_pred_deltas.unsqueeze(0)],
          [gt_boxes[fg_inds]],
          ...,
          self.box_reg_loss_type,
          self.smooth_l1_beta,
      )
  
      # The reg loss is normalized using the total number of regions (R), not the number
      # of foreground regions even though the box regression loss is only defined on
      # foreground regions. Why? Because doing so gives equal training influence to
      # each foreground example. To see how, consider two different minibatches:
      #  (1) Contains a single foreground region
      #  (2) Contains 100 foreground regions
      # If we normalize by the number of foreground regions, the single example in
      # minibatch (1) will be given 100 times as much influence as each foreground
      # example in minibatch (2). Normalizing by the total number of regions, R,
      # means that the single example in minibatch (1) and each of the 100 examples
      # in minibatch (2) are given equal influence.
      return loss_box_reg / max(gt_classes.numel(), 1.0)
  
imports: import logging
  from typing import Callable, Dict, List, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.nn import functional
  from detectron2.config import configurable
  from detectron2.data.detection_utils import get_fed_loss_cls_weights
  from detectron2.layers import ShapeSpec, batched_nms, cat, cross_entropy, nonzero_tuple
  from detectron2.modeling.box_regression import Box2BoxTransform, _dense_box_regression_loss
  from detectron2.structures import Boxes, Instances
  from detectron2.utils.events import get_event_storage
label_desc: Use image node_id 7 for calling the FastRCNNOutputLayers obj's underlying member method code with example usage: obj.box_reg_loss(proposal_boxes, gt_boxes, pred_deltas, gt_classes) and returns: unknown