class_docstr: Standard RPN classification and regression heads described in :paper:`Faster R-CNN`.
  Uses a 3x3 conv to produce a shared hidden state from which one 1x1 conv predicts
  objectness logits for each anchor and a second 1x1 conv predicts bounding-box deltas
  specifying how to deform each anchor into an object proposal.
class_docstr_tok: ["Standard","RPN","classification","and","regression","heads","described","in",":","paper",":","`","Faster","R-CNN","`",".","Uses","a","3x3","conv","to","produce","a","shared","hidden","state","from","which","one","1x1","conv","predicts","objectness","logits","for","each","anchor","and","a","second","1x1","conv","predicts","bounding-box","deltas","specifying","how","to","deform","each","anchor","into","an","object","proposal","."]
docstr: NOTE: this interface is experimental.
  
  Args:
      in_channels (int): number of input feature channels. When using multiple
          input features, they must have the same number of channels.
      num_anchors (int): number of anchors to predict for *each spatial position*
          on the feature map. The total number of anchors for each
          feature map will be `num_anchors * H * W`.
      box_dim (int): dimension of a box, which is also the number of box regression
          predictions to make for each anchor. An axis aligned box has
          box_dim=4, while a rotated box has box_dim=5.
      conv_dims (list[int]): a list of integers representing the output channels
          of N conv layers. Set it to -1 to use the same number of output channels
          as input channels.
docstr_tok: ["NOTE",":","this","interface","is","experimental",".","Args",":","in_channels","(","int",")",":","number","of","input","feature","channels",".","When","using","multiple","input","features",",","they","must","have","the","same","number","of","channels",".","num_anchors","(","int",")",":","number","of","anchors","to","predict","for","*","each","spatial","position","*","on","the","feature","map",".","The","total","number","of","anchors","for","each","feature","map","will","be","`","num_anchors","*","H","*","W","`",".","box_dim","(","int",")",":","dimension","of","a","box",",","which","is","also","the","number","of","box","regression","predictions","to","make","for","each","anchor",".","An","axis","aligned","box","has","box_dim=4",",","while","a","rotated","box","has","box_dim=5",".","conv_dims","(","list","[","int","]",")",":","a","list","of","integers","representing","the","output","channels","of","N","conv","layers",".","Set","it","to","-1","to","use","the","same","number","of","output","channels","as","input","channels","."]
code: def __init__(
      self,
      *,
      in_channels: int,
      num_anchors: int,
      box_dim: int = 4,
      conv_dims: List[int] = (-1,),
  ):
      """
      NOTE: this interface is experimental.
  
      Args:
          in_channels (int): number of input feature channels. When using multiple
              input features, they must have the same number of channels.
          num_anchors (int): number of anchors to predict for *each spatial position*
              on the feature map. The total number of anchors for each
              feature map will be `num_anchors * H * W`.
          box_dim (int): dimension of a box, which is also the number of box regression
              predictions to make for each anchor. An axis aligned box has
              box_dim=4, while a rotated box has box_dim=5.
          conv_dims (list[int]): a list of integers representing the output channels
              of N conv layers. Set it to -1 to use the same number of output channels
              as input channels.
      """
      super().__init__()
      cur_channels = in_channels
      # Keeping the old variable names and structure for backwards compatiblity.
      # Otherwise the old checkpoints will fail to load.
      if len(conv_dims) == 1:
          out_channels = (
              cur_channels if conv_dims[0] == -1 else conv_dims[0]
          )
          # 3x3 conv for the hidden representation
          self.conv = self._get_rpn_conv(cur_channels, out_channels)
          cur_channels = out_channels
      else:
          self.conv = nn.Sequential()
          for k, conv_dim in enumerate(conv_dims):
              out_channels = (
                  cur_channels if conv_dim == -1 else conv_dim
              )
              if out_channels <= 0:
                  raise ValueError(
                      f"Conv output channels should be greater than 0. Got {out_channels}"
                  )
              conv = self._get_rpn_conv(cur_channels, out_channels)
              self.conv.add_module(f"conv{k}", conv)
              cur_channels = out_channels
      # 1x1 conv for predicting objectness logits
      self.objectness_logits = nn.Conv2d(
          cur_channels, num_anchors, kernel_size=1, stride=1
      )
      # 1x1 conv for predicting box2box transform deltas
      self.anchor_deltas = nn.Conv2d(
          cur_channels, num_anchors * box_dim, kernel_size=1, stride=1
      )
  
      # Keeping the order of weights initialization same for backwards compatiblility.
      for layer in self.modules():
          if isinstance(layer, nn.Conv2d):
              nn.init.normal_(layer.weight, std=0.01)
              nn.init.constant_(layer.bias, 0)
  
imports: from typing import Dict, List, Optional, Tuple, Union
  import torch
  import torch.nn.functional
  from torch import nn
  from detectron2.config import configurable
  from detectron2.layers import Conv2d, ShapeSpec, cat
  from detectron2.structures import Boxes, ImageList, Instances, pairwise_iou
  from detectron2.utils.events import get_event_storage
  from detectron2.utils.memory import retry_if_cuda_oom
  from detectron2.utils.registry import Registry
  from ..anchor_generator import build_anchor_generator
  from ..box_regression import Box2BoxTransform, _dense_box_regression_loss
  from ..matcher import Matcher
  from ..sampling import subsample_labels
  from .build import PROPOSAL_GENERATOR_REGISTRY
  from .proposal_utils import find_top_rpn_proposals
label_desc: Use image node_id 1 to create a new StandardRPNHead object from inherited base classes: nn with example: obj = StandardRPNHead()