code: def rpn(self, image, features, inputs):
      featuremap = features[0]
      rpn_label_logits, rpn_box_logits = rpn_head(
          "rpn", featuremap, cfg.RPN.HEAD_DIM, cfg.RPN.NUM_ANCHOR
      )
      anchors = RPNAnchors(
          get_all_anchors(
              stride=cfg.RPN.ANCHOR_STRIDE,
              sizes=cfg.RPN.ANCHOR_SIZES,
              ratios=cfg.RPN.ANCHOR_RATIOS,
              max_size=cfg.PREPROC.MAX_SIZE,
          ),
          inputs["anchor_labels"],
          inputs["anchor_boxes"],
      )
      anchors = anchors.narrow_to(featuremap)
  
      image_shape2d = tf.shape(image)[2:]  # h,w
      pred_boxes_decoded = anchors.decode_logits(
          rpn_box_logits
      )  # fHxfWxNAx4, floatbox
      proposal_boxes, proposal_scores = generate_rpn_proposals(
          tf.reshape(pred_boxes_decoded, [-1, 4]),
          tf.reshape(rpn_label_logits, [-1]),
          image_shape2d,
          cfg.RPN.TRAIN_PRE_NMS_TOPK
          if self.training
          else cfg.RPN.TEST_PRE_NMS_TOPK,
          cfg.RPN.TRAIN_POST_NMS_TOPK
          if self.training
          else cfg.RPN.TEST_POST_NMS_TOPK,
      )
  
      if self.training:
          losses = rpn_losses(
              anchors.gt_labels,
              anchors.encoded_gt_boxes(),
              rpn_label_logits,
              rpn_box_logits,
          )
      else:
          losses = []
  
      return BoxProposals(proposal_boxes), losses
  
imports: from tensorpack import tfv1
  from tensorpack import ModelDesc
  from tensorpack.models import GlobalAvgPooling, l2_regularizer, regularize_cost
  from tensorpack.tfutils import optimizer
  from tensorpack.tfutils.summary import add_moving_summary
  from config import config
  from data import get_all_anchors, get_all_anchors_fpn
  from utils.box_ops import area
  from .None import model_frcnn
  from .None import model_mrcnn
  from .backbone import image_preprocess, resnet_c4_backbone, resnet_conv5, resnet_fpn_backbone
  from .model_box import RPNAnchors, clip_boxes, crop_and_resize, roi_align
  from .model_cascade import CascadeRCNNHead
  from .model_fpn import fpn_model, generate_fpn_proposals, multilevel_roi_align, multilevel_rpn_losses
  from .model_frcnn import BoxProposals, FastRCNNHead, fastrcnn_outputs, fastrcnn_predictions, sample_fast_rcnn_targets
  from .model_mrcnn import maskrcnn_loss, maskrcnn_upXconv_head, unpackbits_masks
  from .model_rpn import generate_rpn_proposals, rpn_head, rpn_losses
label_desc: Use image node_id 3 for calling the ResNetC4Model obj's underlying member method code with example usage: obj.rpn(image, features, inputs) and returns: BoxProposals,  losses