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:
      gt_classes: a long tensor of shape R that contains the gt class label of each proposal.
      num_fed_loss_classes: minimum number of classes to keep when calculating federated loss.
      Will sample negative classes if number of unique gt_classes is smaller than this value.
      num_classes: number of foreground classes
      weight: probabilities used to sample negative classes
  
  Returns:
      Tensor:
          classes to keep when calculating the federated loss, including both unique gt
          classes and sampled negative classes.
docstr_tok: ["Args",":","gt_classes",":","a","long","tensor","of","shape","R","that","contains","the","gt","class","label","of","each","proposal",".","num_fed_loss_classes",":","minimum","number","of","classes","to","keep","when","calculating","federated","loss",".","Will","sample","negative","classes","if","number","of","unique","gt_classes","is","smaller","than","this","value",".","num_classes",":","number","of","foreground","classes","weight",":","probabilities","used","to","sample","negative","classes","Returns",":","Tensor",":","classes","to","keep","when","calculating","the","federated","loss",",","including","both","unique","gt","classes","and","sampled","negative","classes","."]
code: def get_fed_loss_classes(
      self, gt_classes, num_fed_loss_classes, num_classes, weight
  ):
      """
      Args:
          gt_classes: a long tensor of shape R that contains the gt class label of each proposal.
          num_fed_loss_classes: minimum number of classes to keep when calculating federated loss.
          Will sample negative classes if number of unique gt_classes is smaller than this value.
          num_classes: number of foreground classes
          weight: probabilities used to sample negative classes
  
      Returns:
          Tensor:
              classes to keep when calculating the federated loss, including both unique gt
              classes and sampled negative classes.
      """
      unique_gt_classes = torch.unique(gt_classes)
      prob = unique_gt_classes.new_ones(num_classes + 1).float()
      prob[-1] = 0
      if len(unique_gt_classes) < num_fed_loss_classes:
          prob[:num_classes] = weight.float().clone()
          prob[unique_gt_classes] = 0
          sampled_negative_classes = torch.multinomial(
              prob,
              num_fed_loss_classes - len(unique_gt_classes),
              replacement=False,
          )
          fed_loss_classes = torch.cat(
              [unique_gt_classes, sampled_negative_classes]
          )
      else:
          fed_loss_classes = unique_gt_classes
      return fed_loss_classes
  
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 5 for calling the FastRCNNOutputLayers obj's underlying member method code with example usage: obj.get_fed_loss_classes(gt_classes, num_fed_loss_classes, num_classes, weight) and returns: fed_loss_classes