class_docstr: Implements Region Proposal Network (RPN).
  
  Args:
      anchor_generator (AnchorGenerator): module that generates the anchors for a set of feature
          maps.
      head (nn.Module): module that computes the objectness and regression deltas
      fg_iou_thresh (float): minimum IoU between the anchor and the GT box so that they can be
          considered as positive during training of the RPN.
      bg_iou_thresh (float): maximum IoU between the anchor and the GT box so that they can be
          considered as negative during training of the RPN.
      batch_size_per_image (int): number of anchors that are sampled during training of the RPN
          for computing the loss
      positive_fraction (float): proportion of positive anchors in a mini-batch during training
          of the RPN
      pre_nms_top_n (Dict[str, int]): number of proposals to keep before applying NMS. It should
          contain two fields: training and testing, to allow for different values depending
          on training or evaluation
      post_nms_top_n (Dict[str, int]): number of proposals to keep after applying NMS. It should
          contain two fields: training and testing, to allow for different values depending
          on training or evaluation
      nms_thresh (float): NMS threshold used for postprocessing the RPN proposals
code: def __init__(
      self,
      anchor_generator: AnchorGenerator,
      head: nn.Module,
      # Faster-RCNN Training
      fg_iou_thresh: float,
      bg_iou_thresh: float,
      batch_size_per_image: int,
      positive_fraction: float,
      # Faster-RCNN Inference
      pre_nms_top_n: Dict[str, int],
      post_nms_top_n: Dict[str, int],
      nms_thresh: float,
      score_thresh: float = 0.0,
  ) -> None:
      super().__init__()
      self.anchor_generator = anchor_generator
      self.head = head
      self.box_coder = det_utils.BoxCoder(weights=(1.0, 1.0, 1.0, 1.0))
  
      # used during training
      self.box_similarity = box_ops.box_iou
  
      self.proposal_matcher = det_utils.Matcher(
          fg_iou_thresh,
          bg_iou_thresh,
          allow_low_quality_matches=True,
      )
  
      self.fg_bg_sampler = det_utils.BalancedPositiveNegativeSampler(
          batch_size_per_image, positive_fraction
      )
      # used during testing
      self._pre_nms_top_n = pre_nms_top_n
      self._post_nms_top_n = post_nms_top_n
      self.nms_thresh = nms_thresh
      self.score_thresh = score_thresh
      self.min_size = 1e-3
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  from torch import nn, Tensor
  from torch.nn import functional
  from torchvision.ops import boxes, Conv2dNormActivation
  from .None import _utils
  from .anchor_utils import AnchorGenerator
  from .image_list import ImageList
label_desc: Use image node_id 1 to create a new RegionProposalNetwork object from inherited base classes: torch.nn with example: obj = RegionProposalNetwork(anchor_generator, head, fg_iou_thresh, bg_iou_thresh, batch_size_per_image, positive_fraction, pre_nms_top_n, post_nms_top_n, nms_thresh, score_thresh)