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:
      predictions: return values of :meth:`forward()`.
      proposals (list[Instances]): proposals that match the features that were used
          to compute predictions. The fields ``proposal_boxes``, ``gt_boxes``,
          ``gt_classes`` are expected.
  
  Returns:
      Dict[str, Tensor]: dict of losses
docstr_tok: ["Args",":","predictions",":","return","values","of",":","meth",":","`","forward","(",")","`",".","proposals","(","list","[","Instances","]",")",":","proposals","that","match","the","features","that","were","used","to","compute","predictions",".","The","fields","``","proposal_boxes","``",",","``","gt_boxes","``",",","``","gt_classes","``","are","expected",".","Returns",":","Dict","[","str",",","Tensor","]",":","dict","of","losses"]
code: def losses(self, predictions, proposals):
      """
      Args:
          predictions: return values of :meth:`forward()`.
          proposals (list[Instances]): proposals that match the features that were used
              to compute predictions. The fields ``proposal_boxes``, ``gt_boxes``,
              ``gt_classes`` are expected.
  
      Returns:
          Dict[str, Tensor]: dict of losses
      """
      scores, proposal_deltas = predictions
  
      # parse classification outputs
      gt_classes = (
          cat([p.gt_classes for p in proposals], dim=0)
          if len(proposals)
          else torch.empty(0)
      )
      _log_classification_stats(scores, gt_classes)
  
      # parse box regression outputs
      if len(proposals):
          proposal_boxes = cat(
              [p.proposal_boxes.tensor for p in proposals], dim=0
          )  # Nx4
          assert (
              not proposal_boxes.requires_grad
          ), "Proposals should not require gradients!"
          # If "gt_boxes" does not exist, the proposals must be all negative and
          # should not be included in regression loss computation.
          # Here we just use proposal_boxes as an arbitrary placeholder because its
          # value won't be used in self.box_reg_loss().
          gt_boxes = cat(
              [
                  (
                      p.gt_boxes
                      if p.has("gt_boxes")
                      else p.proposal_boxes
                  ).tensor
                  for p in proposals
              ],
              dim=0,
          )
      else:
          proposal_boxes = gt_boxes = torch.empty(
              (0, 4), device=proposal_deltas.device
          )
  
      if self.use_sigmoid_ce:
          loss_cls = self.sigmoid_cross_entropy_loss(scores, gt_classes)
      else:
          loss_cls = cross_entropy(scores, gt_classes, reduction="mean")
  
      losses = {
          "loss_cls": loss_cls,
          "loss_box_reg": self.box_reg_loss(
              proposal_boxes, gt_boxes, proposal_deltas, gt_classes
          ),
      }
      return {
          k: v * self.loss_weight.get(k, 1.0) for k, v in losses.items()
      }
  
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 4 for calling the FastRCNNOutputLayers obj's underlying member method code with example usage: obj.losses(predictions, proposals) and returns: unknown