code: def custom_faster_rcnn_fpn(
      classes,
      transfer=None,
      dataset="custom",
      pretrained_base=True,
      base_network_name="resnet18_v1b",
      norm_layer=nn.BatchNorm,
      norm_kwargs=None,
      sym_norm_layer=None,
      sym_norm_kwargs=None,
      num_fpn_filters=256,
      num_box_head_conv=4,
      num_box_head_conv_filters=256,
      num_box_head_dense_filters=1024,
      **kwargs,
  ):
      r"""Faster RCNN model with resnet base network and FPN on custom dataset.
  
      Parameters
      ----------
      classes : iterable of str
          Names of custom foreground classes. `len(classes)` is the number of foreground classes.
      transfer : str or None
          Dataset from witch to transfer from. If not `None`, will try to reuse pre-trained weights
          from faster RCNN networks trained on other dataset, specified by the parameter.
      dataset : str, default 'custom'
          Dataset name attached to the network name
      pretrained_base : bool or str
          Boolean value controls whether to load the default pretrained weights for model.
          String value represents the hashtag for a certain version of pretrained weights.
      base_network_name : str, default 'resnet18_v1b'
          base network for mask RCNN. Currently support: 'resnet18_v1b', 'resnet50_v1b',
          and 'resnet101_v1d'
      norm_layer : nn.HybridBlock, default nn.BatchNorm
          Gluon normalization layer to use. Default is frozen batch normalization layer.
      norm_kwargs : dict
          Keyword arguments for gluon normalization layer
      sym_norm_layer : nn.SymbolBlock, default `None`
          Symbol normalization layer to use in FPN. This is due to FPN being implemented using
          SymbolBlock. Default is `None`, meaning no normalization layer will be used in FPN.
      sym_norm_kwargs : dict
          Keyword arguments for symbol normalization layer used in FPN.
      num_fpn_filters : int, default 256
          Number of filters for FPN output layers.
      num_box_head_conv : int, default 4
          Number of convolution layers to use in box head if batch normalization is not frozen.
      num_box_head_conv_filters : int, default 256
          Number of filters for convolution layers in box head.
          Only applicable if batch normalization is not frozen.
      num_box_head_dense_filters : int, default 1024
          Number of hidden units for the last fully connected layer in box head.
      ctx : Context, default CPU
          The context in which to load the pretrained weights.
      root : str, default '~/.mxnet/models'
          Location for keeping the model parameters.
  
      Returns
      -------
      mxnet.gluon.HybridBlock
          Hybrid faster RCNN network.
      """
      use_global_stats = norm_layer is nn.BatchNorm
      train_patterns = (
          "|".join(
              [
                  ".*dense",
                  ".*rpn",
                  ".*down(2|3|4)_conv",
                  ".*layers(2|3|4)_conv",
                  "P",
              ]
          )
          if use_global_stats
          else "(?!.*moving)"
      )  # excluding symbol bn moving mean and var'''
  
      if transfer is None:
          features, top_features, box_features = custom_rcnn_fpn(
              pretrained_base,
              base_network_name,
              norm_layer,
              norm_kwargs,
              sym_norm_layer,
              sym_norm_kwargs,
              num_fpn_filters,
              num_box_head_conv,
              num_box_head_conv_filters,
              num_box_head_dense_filters,
          )
          return get_doublehead_rcnn(
              name="fpn_" + base_network_name,
              dataset=dataset,
              features=features,
              top_features=top_features,
              classes=classes,
              box_features=box_features,
              train_patterns=train_patterns,
              **kwargs,
          )
      else:
          from ....model_zoo import get_model
  
          module_list = ["fpn"]
          num_devices = 0
          if norm_layer is SyncBatchNorm:
              module_list.append("syncbn")
              num_devices = norm_kwargs["num_devices"]
          net = get_model(
              "_".join(
                  ["faster_rcnn"]
                  + module_list
                  + [base_network_name, str(transfer)]
              ),
              pretrained=True,
              per_device_batch_size=kwargs["per_device_batch_size"],
              num_devices=num_devices,
          )
          reuse_classes = [x for x in classes if x in net.classes]
          net.reset_class(classes, reuse_weights=reuse_classes)
      return net
  
imports: from __future__ import absolute_import
  import os
  import mxnet
  from mxnet import autograd
  from mxnet.gluon import nn
  from mxnet.gluon.contrib.nn import SyncBatchNorm
  from mxnet.gluon.nn import BatchNorm
  from mxnet.gluon.block import HybridBlock
  from .rcnn_target import RCNNTargetSampler, RCNNTargetGenerator
  from ..rcnn import custom_rcnn_fpn
  from ....model_zoo.rcnn import RCNN
  from ....model_zoo.rcnn.rpn import RPN
label_desc: Use image node_id 3 for calling a global function with example usage: custom_faster_rcnn_fpn(classes, transfer, dataset, pretrained_base, base_network_name, norm_layer, norm_kwargs, sym_norm_layer, sym_norm_kwargs, num_fpn_filters, num_box_head_conv, num_box_head_conv_filters, num_box_head_dense_filters) and returns: net, get_doublehead_rcnn