code: def draw_final_outputs(img, results):
      """
      Args:
          results: [DetectionResult]
      """
      if len(results) == 0:
          return img
  
      # Display in largest to smallest order to reduce occlusion
      boxes = np.asarray([r.box for r in results])
      areas = np_area(boxes)
      sorted_inds = np.argsort(-areas)
  
      ret = img
      tags = []
  
      for result_id in sorted_inds:
          r = results[result_id]
          if r.mask is not None:
              ret = draw_mask(ret, r.mask)
  
      for r in results:
          tags.append(
              "{},{:.2f}".format(
                  cfg.DATA.CLASS_NAMES[r.class_id], r.score
              )
          )
      ret = viz.draw_boxes(ret, boxes, tags)
      return ret
  
file_path: tensorpack/examples/FasterRCNN/viz.py
imports: import numpy
  from tensorpack.utils import viz
  from tensorpack.utils.palette import PALETTE_RGB
  from config import config
  from utils.np_box_ops import area
  from utils.np_box_ops import iou
  from common import polygons_to_mask
label_desc: Use image node_id 4 for calling a global function with example usage: draw_final_outputs(img, results) and returns: ret, img