code: def get_out(
      conv_fpn_feat,
      prefix,
      stride,
      landmark=False,
      lr_mult=1.0,
      shared_vars=None,
  ):
      A = config.NUM_ANCHORS
      bbox_pred_len = 4
      landmark_pred_len = 10
      if config.USE_BLUR:
          bbox_pred_len = 5
      if config.USE_OCCLUSION:
          landmark_pred_len = 15
      ret_group = []
      num_anchors = config.RPN_ANCHOR_CFG[str(stride)]["NUM_ANCHORS"]
      label = mx.symbol.Variable(
          name="%s_label_stride%d" % (prefix, stride)
      )
      bbox_target = mx.symbol.Variable(
          name="%s_bbox_target_stride%d" % (prefix, stride)
      )
      bbox_weight = mx.symbol.Variable(
          name="%s_bbox_weight_stride%d" % (prefix, stride)
      )
      if landmark:
          landmark_target = mx.symbol.Variable(
              name="%s_landmark_target_stride%d" % (prefix, stride)
          )
          landmark_weight = mx.symbol.Variable(
              name="%s_landmark_weight_stride%d" % (prefix, stride)
          )
      rpn_relu = conv_fpn_feat[stride]
      maxout_stat = 0
      if (
          config.USE_MAXOUT >= 1
          and stride == config.RPN_FEAT_STRIDE[-1]
      ):
          maxout_stat = 1
      if (
          config.USE_MAXOUT >= 2
          and stride != config.RPN_FEAT_STRIDE[-1]
      ):
          maxout_stat = 2
  
      if maxout_stat == 0:
          rpn_cls_score = conv_only(
              rpn_relu,
              "%s_rpn_cls_score_stride%d" % (prefix, stride),
              2 * num_anchors,
              kernel=(1, 1),
              pad=(0, 0),
              stride=(1, 1),
              shared_weight=shared_vars[0][0],
              shared_bias=shared_vars[0][1],
          )
      elif maxout_stat == 1:
          cls_list = []
          for a in range(num_anchors):
              rpn_cls_score_bg = conv_only(
                  rpn_relu,
                  "%s_rpn_cls_score_stride%d_anchor%d_bg"
                  % (prefix, stride, a),
                  3,
                  kernel=(1, 1),
                  pad=(0, 0),
                  stride=(1, 1),
              )
              rpn_cls_score_bg = mx.sym.max(
                  rpn_cls_score_bg, axis=1, keepdims=True
              )
              cls_list.append(rpn_cls_score_bg)
              rpn_cls_score_fg = conv_only(
                  rpn_relu,
                  "%s_rpn_cls_score_stride%d_anchor%d_fg"
                  % (prefix, stride, a),
                  1,
                  kernel=(1, 1),
                  pad=(0, 0),
                  stride=(1, 1),
              )
              cls_list.append(rpn_cls_score_fg)
          rpn_cls_score = mx.sym.concat(
              *cls_list,
              dim=1,
              name="%s_rpn_cls_score_stride%d" % (prefix, stride),
          )
      else:
          cls_list = []
          for a in range(num_anchors):
              rpn_cls_score_bg = conv_only(
                  rpn_relu,
                  "%s_rpn_cls_score_stride%d_anchor%d_bg"
                  % (prefix, stride, a),
                  1,
                  kernel=(1, 1),
                  pad=(0, 0),
                  stride=(1, 1),
              )
              cls_list.append(rpn_cls_score_bg)
              rpn_cls_score_fg = conv_only(
                  rpn_relu,
                  "%s_rpn_cls_score_stride%d_anchor%d_fg"
                  % (prefix, stride, a),
                  3,
                  kernel=(1, 1),
                  pad=(0, 0),
                  stride=(1, 1),
              )
              rpn_cls_score_fg = mx.sym.max(
                  rpn_cls_score_fg, axis=1, keepdims=True
              )
              cls_list.append(rpn_cls_score_fg)
          rpn_cls_score = mx.sym.concat(
              *cls_list,
              dim=1,
              name="%s_rpn_cls_score_stride%d" % (prefix, stride),
          )
  
      rpn_bbox_pred = conv_only(
          rpn_relu,
          "%s_rpn_bbox_pred_stride%d" % (prefix, stride),
          bbox_pred_len * num_anchors,
          kernel=(1, 1),
          pad=(0, 0),
          stride=(1, 1),
          shared_weight=shared_vars[1][0],
          shared_bias=shared_vars[1][1],
      )
  
      # prepare rpn data
      if not config.FBN:
          rpn_cls_score_reshape = mx.symbol.Reshape(
              data=rpn_cls_score,
              shape=(0, 2, -1),
              name="%s_rpn_cls_score_reshape_stride%s"
              % (prefix, stride),
          )
      else:
          rpn_cls_score_reshape = mx.symbol.Reshape(
              data=rpn_cls_score,
              shape=(0, 2, -1),
              name="%s_rpn_cls_score_reshape_stride%s_pre"
              % (prefix, stride),
          )
          rpn_cls_score_reshape = mx.symbol.BatchNorm(
              rpn_cls_score_reshape,
              fix_gamma=True,
              eps=2e-5,
              name="%s_rpn_cls_score_reshape_stride%s"
              % (prefix, stride),
          )
  
      rpn_bbox_pred_reshape = mx.symbol.Reshape(
          data=rpn_bbox_pred,
          shape=(0, 0, -1),
          name="%s_rpn_bbox_pred_reshape_stride%s" % (prefix, stride),
      )
      if landmark:
          rpn_landmark_pred = conv_only(
              rpn_relu,
              "%s_rpn_landmark_pred_stride%d" % (prefix, stride),
              landmark_pred_len * num_anchors,
              kernel=(1, 1),
              pad=(0, 0),
              stride=(1, 1),
              shared_weight=shared_vars[2][0],
              shared_bias=shared_vars[2][1],
          )
          rpn_landmark_pred_reshape = mx.symbol.Reshape(
              data=rpn_landmark_pred,
              shape=(0, 0, -1),
              name="%s_rpn_landmark_pred_reshape_stride%s"
              % (prefix, stride),
          )
  
      if config.TRAIN.RPN_ENABLE_OHEM >= 2:
          label, anchor_weight = mx.sym.Custom(
              op_type="rpn_fpn_ohem3",
              stride=int(stride),
              network=config.network,
              dataset=config.dataset,
              prefix=prefix,
              cls_score=rpn_cls_score_reshape,
              labels=label,
          )
  
          _bbox_weight = mx.sym.tile(
              anchor_weight, (1, 1, bbox_pred_len)
          )
          _bbox_weight = _bbox_weight.reshape(
              (0, -1, A * bbox_pred_len)
          ).transpose((0, 2, 1))
          bbox_weight = mx.sym.elemwise_mul(
              bbox_weight,
              _bbox_weight,
              name="%s_bbox_weight_mul_stride%s" % (prefix, stride),
          )
  
          if landmark:
              _landmark_weight = mx.sym.tile(
                  anchor_weight, (1, 1, landmark_pred_len)
              )
              _landmark_weight = _landmark_weight.reshape(
                  (0, -1, A * landmark_pred_len)
              ).transpose((0, 2, 1))
              landmark_weight = mx.sym.elemwise_mul(
                  landmark_weight,
                  _landmark_weight,
                  name="%s_landmark_weight_mul_stride%s"
                  % (prefix, stride),
              )
          # if not config.FACE_LANDMARK:
          #  label, bbox_weight = mx.sym.Custom(op_type='rpn_fpn_ohem', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight , labels = label)
          # else:
          #  label, bbox_weight, landmark_weight = mx.sym.Custom(op_type='rpn_fpn_ohem2', stride=int(stride), cls_score=rpn_cls_score_reshape, bbox_weight = bbox_weight, landmark_weight=landmark_weight, labels = label)
      # cls loss
      rpn_cls_prob = mx.symbol.SoftmaxOutput(
          data=rpn_cls_score_reshape,
          label=label,
          multi_output=True,
          normalization="valid",
          use_ignore=True,
          ignore_label=-1,
          grad_scale=lr_mult,
          name="%s_rpn_cls_prob_stride%d" % (prefix, stride),
      )
      ret_group.append(rpn_cls_prob)
      ret_group.append(mx.sym.BlockGrad(label))
  
      # bbox loss
      bbox_diff = rpn_bbox_pred_reshape - bbox_target
      bbox_diff = bbox_diff * bbox_weight
      rpn_bbox_loss_ = mx.symbol.smooth_l1(
          name="%s_rpn_bbox_loss_stride%d_" % (prefix, stride),
          scalar=3.0,
          data=bbox_diff,
      )
      rpn_bbox_loss = mx.sym.MakeLoss(
          name="%s_rpn_bbox_loss_stride%d" % (prefix, stride),
          data=rpn_bbox_loss_,
          grad_scale=1.0 * lr_mult / (config.TRAIN.RPN_BATCH_SIZE),
      )
      ret_group.append(rpn_bbox_loss)
      ret_group.append(mx.sym.BlockGrad(bbox_weight))
  
      # landmark loss
      if landmark:
          landmark_diff = rpn_landmark_pred_reshape - landmark_target
          landmark_diff = landmark_diff * landmark_weight
          rpn_landmark_loss_ = mx.symbol.smooth_l1(
              name="%s_rpn_landmark_loss_stride%d_" % (prefix, stride),
              scalar=3.0,
              data=landmark_diff,
          )
          rpn_landmark_loss = mx.sym.MakeLoss(
              name="%s_rpn_landmark_loss_stride%d" % (prefix, stride),
              data=rpn_landmark_loss_,
              grad_scale=0.5 * lr_mult / (config.TRAIN.RPN_BATCH_SIZE),
          )
          ret_group.append(rpn_landmark_loss)
          ret_group.append(mx.sym.BlockGrad(landmark_weight))
      return ret_group
  
file_path: insightface/detection/retinaface/rcnn/symbol/symbol_mnet.py
imports: import mxnet
  import mxnet.ndarray
  import mxnet.gluon
  import mxnet.gluon.nn
  import mxnet.autograd
  import numpy
  from rcnn.config import config
  from rcnn.PY_OP import rpn_fpn_ohem3
  from rcnn.symbol.symbol_common import get_sym_train
label_desc: Use image node_id 8 for calling a global function with example usage: get_out(conv_fpn_feat, prefix, stride, landmark, lr_mult, shared_vars) and returns: ret_group