code: def multilevel_roi_align(features, rcnn_boxes, resolution):
      """
      Args:
          features ([tf.Tensor]): 4 FPN feature level 2-5
          rcnn_boxes (tf.Tensor): nx4 boxes
          resolution (int): output spatial resolution
      Returns:
          NxC x res x res
      """
      assert len(features) == 4, features
      # Reassign rcnn_boxes to levels
      level_ids, level_boxes = fpn_map_rois_to_levels(rcnn_boxes)
      all_rois = []
  
      # Crop patches from corresponding levels
      for i, boxes, featuremap in zip(
          itertools.count(), level_boxes, features
      ):
          with tf.name_scope("roi_level{}".format(i + 2)):
              boxes_on_featuremap = boxes * (
                  1.0 / cfg.FPN.ANCHOR_STRIDES[i]
              )
              all_rois.append(
                  roi_align(featuremap, boxes_on_featuremap, resolution)
              )
  
      # this can fail if using TF<=1.8 with MKL build
      all_rois = tf.concat(all_rois, axis=0)  # NCHW
      # Unshuffle to the original order, to match the original samples
      level_id_perm = tf.concat(
          level_ids, axis=0
      )  # A permutation of 1~N
      level_id_invert_perm = tf.math.invert_permutation(level_id_perm)
      all_rois = tf.gather(
          all_rois, level_id_invert_perm, name="output"
      )
      return all_rois
  
imports: import itertools
  import numpy
  import tensorflow
  from tensorpack import tfv1
  from tensorpack.models import Conv2D, FixedUnPooling, MaxPooling, layer_register
  from tensorpack.tfutils.argscope import argscope
  from tensorpack.tfutils.scope_utils import under_name_scope
  from tensorpack.tfutils.summary import add_moving_summary
  from tensorpack.tfutils.tower import get_current_tower_context
  from tensorpack.utils.argtools import memoized
  from config import config
  from utils.box_ops import area
  from .backbone import GroupNorm
  from .model_box import roi_align
  from .model_rpn import generate_rpn_proposals, rpn_losses, get_all_anchors
label_desc: Use image node_id 3 for calling a global function with example usage: multilevel_roi_align(features, rcnn_boxes, resolution) and returns: all_rois