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: NOTE: this interface is experimental.
  
  Args:
      input_shape (ShapeSpec): shape of the input feature to this module
      box2box_transform (Box2BoxTransform or Box2BoxTransformRotated):
      num_classes (int): number of foreground classes
      test_score_thresh (float): threshold to filter predictions results.
      test_nms_thresh (float): NMS threshold for prediction results.
      test_topk_per_image (int): number of top predictions to produce per image.
      cls_agnostic_bbox_reg (bool): whether to use class agnostic for bbox regression
      smooth_l1_beta (float): transition point from L1 to L2 loss. Only used if
          `box_reg_loss_type` is "smooth_l1"
      box_reg_loss_type (str): Box regression loss type. One of: "smooth_l1", "giou",
          "diou", "ciou"
      loss_weight (float|dict): weights to use for losses. Can be single float for weighting
          all losses, or a dict of individual weightings. Valid dict keys are:
              * "loss_cls": applied to classification loss
              * "loss_box_reg": applied to box regression loss
      use_fed_loss (bool): whether to use federated loss which samples additional negative
          classes to calculate the loss
      use_sigmoid_ce (bool): whether to calculate the loss using weighted average of binary
          cross entropy with logits. This could be used together with federated loss
      get_fed_loss_cls_weights (Callable): a callable which takes dataset name and frequency
          weight power, and returns the probabilities to sample negative classes for
          federated loss. The implementation can be found in
          detectron2/data/detection_utils.py
      fed_loss_num_classes (int): number of federated classes to keep in total
docstr_tok: ["NOTE",":","this","interface","is","experimental",".","Args",":","input_shape","(","ShapeSpec",")",":","shape","of","the","input","feature","to","this","module","box2box_transform","(","Box2BoxTransform","or","Box2BoxTransformRotated",")",":","num_classes","(","int",")",":","number","of","foreground","classes","test_score_thresh","(","float",")",":","threshold","to","filter","predictions","results",".","test_nms_thresh","(","float",")",":","NMS","threshold","for","prediction","results",".","test_topk_per_image","(","int",")",":","number","of","top","predictions","to","produce","per","image",".","cls_agnostic_bbox_reg","(","bool",")",":","whether","to","use","class","agnostic","for","bbox","regression","smooth_l1_beta","(","float",")",":","transition","point","from","L1","to","L2","loss",".","Only","used","if","`","box_reg_loss_type","`","is","``","smooth_l1","''","box_reg_loss_type","(","str",")",":","Box","regression","loss","type",".","One","of",":","``","smooth_l1","''",",","``","giou","''",",","``","diou","''",",","``","ciou","''","loss_weight","(","float|dict",")",":","weights","to","use","for","losses",".","Can","be","single","float","for","weighting","all","losses",",","or","a","dict","of","individual","weightings",".","Valid","dict","keys","are",":","*","``","loss_cls","''",":","applied","to","classification","loss","*","``","loss_box_reg","''",":","applied","to","box","regression","loss","use_fed_loss","(","bool",")",":","whether","to","use","federated","loss","which","samples","additional","negative","classes","to","calculate","the","loss","use_sigmoid_ce","(","bool",")",":","whether","to","calculate","the","loss","using","weighted","average","of","binary","cross","entropy","with","logits",".","This","could","be","used","together","with","federated","loss","get_fed_loss_cls_weights","(","Callable",")",":","a","callable","which","takes","dataset","name","and","frequency","weight","power",",","and","returns","the","probabilities","to","sample","negative","classes","for","federated","loss",".","The","implementation","can","be","found","in","detectron2\/data\/detection_utils.py","fed_loss_num_classes","(","int",")",":","number","of","federated","classes","to","keep","in","total"]
code: def __init__(
      self,
      input_shape: ShapeSpec,
      *,
      box2box_transform,
      num_classes: int,
      test_score_thresh: float = 0.0,
      test_nms_thresh: float = 0.5,
      test_topk_per_image: int = 100,
      cls_agnostic_bbox_reg: bool = False,
      smooth_l1_beta: float = 0.0,
      box_reg_loss_type: str = "smooth_l1",
      loss_weight: Union[float, Dict[str, float]] = 1.0,
      use_fed_loss: bool = False,
      use_sigmoid_ce: bool = False,
      get_fed_loss_cls_weights: Optional[Callable] = None,
      fed_loss_num_classes: int = 50,
  ):
      """
      NOTE: this interface is experimental.
  
      Args:
          input_shape (ShapeSpec): shape of the input feature to this module
          box2box_transform (Box2BoxTransform or Box2BoxTransformRotated):
          num_classes (int): number of foreground classes
          test_score_thresh (float): threshold to filter predictions results.
          test_nms_thresh (float): NMS threshold for prediction results.
          test_topk_per_image (int): number of top predictions to produce per image.
          cls_agnostic_bbox_reg (bool): whether to use class agnostic for bbox regression
          smooth_l1_beta (float): transition point from L1 to L2 loss. Only used if
              `box_reg_loss_type` is "smooth_l1"
          box_reg_loss_type (str): Box regression loss type. One of: "smooth_l1", "giou",
              "diou", "ciou"
          loss_weight (float|dict): weights to use for losses. Can be single float for weighting
              all losses, or a dict of individual weightings. Valid dict keys are:
                  * "loss_cls": applied to classification loss
                  * "loss_box_reg": applied to box regression loss
          use_fed_loss (bool): whether to use federated loss which samples additional negative
              classes to calculate the loss
          use_sigmoid_ce (bool): whether to calculate the loss using weighted average of binary
              cross entropy with logits. This could be used together with federated loss
          get_fed_loss_cls_weights (Callable): a callable which takes dataset name and frequency
              weight power, and returns the probabilities to sample negative classes for
              federated loss. The implementation can be found in
              detectron2/data/detection_utils.py
          fed_loss_num_classes (int): number of federated classes to keep in total
      """
      super().__init__()
      if isinstance(input_shape, int):  # some backward compatibility
          input_shape = ShapeSpec(channels=input_shape)
      self.num_classes = num_classes
      input_size = (
          input_shape.channels
          * (input_shape.width or 1)
          * (input_shape.height or 1)
      )
      # prediction layer for num_classes foreground classes and one background class (hence + 1)
      self.cls_score = nn.Linear(input_size, num_classes + 1)
      num_bbox_reg_classes = 1 if cls_agnostic_bbox_reg else num_classes
      box_dim = len(box2box_transform.weights)
      self.bbox_pred = nn.Linear(
          input_size, num_bbox_reg_classes * box_dim
      )
  
      nn.init.normal_(self.cls_score.weight, std=0.01)
      nn.init.normal_(self.bbox_pred.weight, std=0.001)
      for l in [self.cls_score, self.bbox_pred]:
          nn.init.constant_(l.bias, 0)
  
      self.box2box_transform = box2box_transform
      self.smooth_l1_beta = smooth_l1_beta
      self.test_score_thresh = test_score_thresh
      self.test_nms_thresh = test_nms_thresh
      self.test_topk_per_image = test_topk_per_image
      self.box_reg_loss_type = box_reg_loss_type
      if isinstance(loss_weight, float):
          loss_weight = {
              "loss_cls": loss_weight,
              "loss_box_reg": loss_weight,
          }
      self.loss_weight = loss_weight
      self.use_fed_loss = use_fed_loss
      self.use_sigmoid_ce = use_sigmoid_ce
      self.fed_loss_num_classes = fed_loss_num_classes
  
      if self.use_fed_loss:
          assert (
              self.use_sigmoid_ce
          ), "Please use sigmoid cross entropy loss with federated loss"
          fed_loss_cls_weights = get_fed_loss_cls_weights()
          assert (
              len(fed_loss_cls_weights) == self.num_classes
          ), "Please check the provided fed_loss_cls_weights. Their size should match num_classes"
          self.register_buffer(
              "fed_loss_cls_weights", fed_loss_cls_weights
          )
  
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 1 to create a new FastRCNNOutputLayers object from inherited base classes: nn with example: obj = FastRCNNOutputLayers(input_shape)