code: def fpn_map_rois_to_levels(boxes):
      """
      Assign boxes to level 2~5.
  
      Args:
          boxes (nx4):
  
      Returns:
          [tf.Tensor]: 4 tensors for level 2-5. Each tensor is a vector of indices of boxes in its level.
          [tf.Tensor]: 4 tensors, the gathered boxes in each level.
  
      Be careful that the returned tensor could be empty.
      """
      sqrtarea = tf.sqrt(tf_area(boxes))
      level = tf.cast(
          tf.floor(
              4
              + tf.math.log(sqrtarea * (1.0 / 224) + 1e-6)
              * (1.0 / np.log(2))
          ),
          tf.int32,
      )
  
      # RoI levels range from 2~5 (not 6)
      level_ids = [
          tf.where(level <= 2),
          tf.where(tf.equal(level, 3)),  # == is not supported
          tf.where(tf.equal(level, 4)),
          tf.where(level >= 5),
      ]
      level_ids = [
          tf.reshape(x, [-1], name="roi_level{}_id".format(i + 2))
          for i, x in enumerate(level_ids)
      ]
      num_in_levels = [
          tf.size(x, name="num_roi_level{}".format(i + 2))
          for i, x in enumerate(level_ids)
      ]
      add_moving_summary(*num_in_levels)
  
      level_boxes = [tf.gather(boxes, ids) for ids in level_ids]
      return level_ids, level_boxes
  
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 2 for calling a global function with example usage: fpn_map_rois_to_levels(boxes) and returns: level_ids,  level_boxes