class_docstr: Implements Region Proposal Network (RPN).
  
  Arguments:
      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]): 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]): 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
class_docstr_tok: ["Implements","Region","Proposal","Network","(","RPN",")",".","Arguments",":","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","]",")",":","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","]",")",":","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"]
docstr: 获取每张预测特征图上预测概率排前pre_nms_top_n的anchors索引值
  Args:
      objectness: Tensor(每张图像的预测目标概率信息 )
      num_anchors_per_level: List（每个预测特征层上的预测的anchors个数）
  Returns:
docstr_tok: ["\u83b7\u53d6\u6bcf\u5f20\u9884\u6d4b\u7279\u5f81\u56fe\u4e0a\u9884\u6d4b\u6982\u7387\u6392\u524dpre_nms_top_n\u7684anchors\u7d22\u5f15\u503c","Args",":","objectness",":","Tensor","(","\u6bcf\u5f20\u56fe\u50cf\u7684\u9884\u6d4b\u76ee\u6807\u6982\u7387\u4fe1\u606f",")","num_anchors_per_level",":","List\uff08\u6bcf\u4e2a\u9884\u6d4b\u7279\u5f81\u5c42\u4e0a\u7684\u9884\u6d4b\u7684anchors\u4e2a\u6570\uff09","Returns",":"]
code: def _get_top_n_idx(self, objectness, num_anchors_per_level):
      # type: (Tensor, List[int]) -> Tensor
      """
      获取每张预测特征图上预测概率排前pre_nms_top_n的anchors索引值
      Args:
          objectness: Tensor(每张图像的预测目标概率信息 )
          num_anchors_per_level: List（每个预测特征层上的预测的anchors个数）
      Returns:
  
      """
      r = []  # 记录每个预测特征层上预测目标概率前pre_nms_top_n的索引信息
      offset = 0
      # 遍历每个预测特征层上的预测目标概率信息
      for ob in objectness.split(num_anchors_per_level, 1):
          if torchvision._is_tracing():
              (
                  num_anchors,
                  pre_nms_top_n,
              ) = _onnx_get_num_anchors_and_pre_nms_top_n(
                  ob, self.pre_nms_top_n()
              )
          else:
              num_anchors = ob.shape[1]  # 预测特征层上的预测的anchors个数
              pre_nms_top_n = min(self.pre_nms_top_n(), num_anchors)
  
          # Returns the k largest elements of the given input tensor along a given dimension
          _, top_n_idx = ob.topk(pre_nms_top_n, dim=1)
          r.append(top_n_idx + offset)
          offset += num_anchors
      return torch.cat(r, dim=1)
  
imports: from typing import List, Optional, Dict, Tuple
  import torch
  from torch import nn, Tensor
  from torch.nn import functional
  import torchvision
  from .None import det_utils
  from .None import boxes
  from .image_list import ImageList
label_desc: Use image node_id 5 for calling the RegionProposalNetwork obj's underlying member method code with example usage: obj._get_top_n_idx(objectness, num_anchors_per_level) and returns: torch