class_docstr: RPN Head
  
  Args:
      anchor_generator (object): `AnchorGenerator` instance
      rpn_target_assign (object): `RPNTargetAssign` instance
      train_proposal (object): `GenerateProposals` instance for training
      test_proposal (object): `GenerateProposals` instance for testing
      num_classes (int): number of classes in rpn output
docstr: Sample proposals and Calculate rpn loss.
  
  Args:
      im_info(Variable): The information of image with shape [N, 3] with
          shape (height, width, scale).
      gt_box(Variable): The ground-truth bounding boxes with shape [M, 4].
          M is the number of groundtruth.
      is_crowd(Variable): Indicates groud-truth is crowd or not with
          shape [M, 1]. M is the number of groundtruth.
  
  Returns:
      Type: dict
          rpn_cls_loss(Variable): RPN classification loss.
          rpn_bbox_loss(Variable): RPN bounding box regression loss.
docstr_tok: ["Sample","proposals","and","Calculate","rpn","loss",".","Args",":","im_info","(","Variable",")",":","The","information","of","image","with","shape","[","N",",","3","]","with","shape","(","height",",","width",",","scale",")",".","gt_box","(","Variable",")",":","The","ground-truth","bounding","boxes","with","shape","[","M",",","4","]",".","M","is","the","number","of","groundtruth",".","is_crowd","(","Variable",")",":","Indicates","groud-truth","is","crowd","or","not","with","shape","[","M",",","1","]",".","M","is","the","number","of","groundtruth",".","Returns",":","Type",":","dict","rpn_cls_loss","(","Variable",")",":","RPN","classification","loss",".","rpn_bbox_loss","(","Variable",")",":","RPN","bounding","box","regression","loss","."]
code: def get_loss(self, im_info, gt_box, is_crowd, gt_label=None):
      """
      Sample proposals and Calculate rpn loss.
  
      Args:
          im_info(Variable): The information of image with shape [N, 3] with
              shape (height, width, scale).
          gt_box(Variable): The ground-truth bounding boxes with shape [M, 4].
              M is the number of groundtruth.
          is_crowd(Variable): Indicates groud-truth is crowd or not with
              shape [M, 1]. M is the number of groundtruth.
  
      Returns:
          Type: dict
              rpn_cls_loss(Variable): RPN classification loss.
              rpn_bbox_loss(Variable): RPN bounding box regression loss.
  
      """
      rpn_cls, rpn_bbox, anchor, anchor_var = self._get_loss_input()
      if self.num_classes == 1:
          # self.rpn_target_assign
          (
              score_pred,
              loc_pred,
              score_tgt,
              loc_tgt,
              bbox_weight,
          ) = fluid.layers.rpn_target_assign(
              bbox_pred=rpn_bbox,
              cls_logits=rpn_cls,
              anchor_box=anchor,
              anchor_var=anchor_var,
              gt_boxes=gt_box,
              is_crowd=is_crowd,
              im_info=im_info,
              rpn_batch_size_per_im=self.rpn_target_assign.rpn_batch_size_per_im,
              rpn_straddle_thresh=self.rpn_target_assign.rpn_straddle_thresh,
              rpn_fg_fraction=self.rpn_target_assign.rpn_fg_fraction,
              rpn_positive_overlap=self.rpn_target_assign.rpn_positive_overlap,
              rpn_negative_overlap=self.rpn_target_assign.rpn_negative_overlap,
              use_random=self.rpn_target_assign.use_random,
          )
          score_tgt = fluid.layers.cast(x=score_tgt, dtype="float32")
          score_tgt.stop_gradient = True
          rpn_cls_loss = fluid.layers.sigmoid_cross_entropy_with_logits(
              x=score_pred, label=score_tgt
          )
      else:
          (
              score_pred,
              loc_pred,
              score_tgt,
              loc_tgt,
              bbox_weight,
          ) = self.rpn_target_assign(
              bbox_pred=rpn_bbox,
              cls_logits=rpn_cls,
              anchor_box=anchor,
              anchor_var=anchor_var,
              gt_boxes=gt_box,
              gt_labels=gt_label,
              is_crowd=is_crowd,
              num_classes=self.num_classes,
              im_info=im_info,
          )
          labels_int64 = fluid.layers.cast(x=score_tgt, dtype="int64")
          labels_int64.stop_gradient = True
          rpn_cls_loss = fluid.layers.softmax_with_cross_entropy(
              logits=score_pred,
              label=labels_int64,
              numeric_stable_mode=True,
          )
  
      rpn_cls_loss = fluid.layers.reduce_mean(
          rpn_cls_loss, name="loss_rpn_cls"
      )
  
      loc_tgt = fluid.layers.cast(x=loc_tgt, dtype="float32")
      loc_tgt.stop_gradient = True
      rpn_reg_loss = fluid.layers.smooth_l1(
          x=loc_pred,
          y=loc_tgt,
          sigma=3.0,
          inside_weight=bbox_weight,
          outside_weight=bbox_weight,
      )
      rpn_reg_loss = fluid.layers.reduce_sum(
          rpn_reg_loss, name="loss_rpn_bbox"
      )
      score_shape = fluid.layers.shape(score_tgt)
      score_shape = fluid.layers.cast(x=score_shape, dtype="float32")
      norm = fluid.layers.reduce_prod(score_shape)
      norm.stop_gradient = True
      rpn_reg_loss = rpn_reg_loss / norm
      return {
          "rpn_cls_loss": rpn_cls_loss,
          "rpn_reg_loss": rpn_reg_loss,
      }
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from paddle import fluid
  from paddle.fluid.param_attr import ParamAttr
  from paddle.fluid.initializer import Normal
  from paddle.fluid.regularizer import L2Decay
label_desc: Use image node_id 6 for calling the RPNHead obj's underlying member method code with example usage: obj.get_loss(im_info, gt_box, is_crowd, gt_label) and returns: dict