code: def draw_anchors(pred_dict, image, anchor_num=None):
      """
      Draws positive anchors used as "correct" in RPN
      """
      anchors = pred_dict["all_anchors"]
      x_min = anchors[:, 0]
      y_min = anchors[:, 1]
      x_max = anchors[:, 2]
      y_max = anchors[:, 3]
  
      height = pred_dict["image_shape"][0]
      width = pred_dict["image_shape"][1]
  
      areas = np.unique(np.round((x_max - x_min) * (y_max - y_min)))
  
      inside_filter = np.logical_and.reduce(
          (
              (x_min >= 0),
              (y_min >= 0),
              (x_max < width),
              (y_max < height),
          )
      )
  
      x_negative = x_min < 0
      y_negative = y_min < 0
      x_outof = x_max >= width
      y_outof = y_max >= height
  
      if anchor_num is None:
          logger.debug("{} unique areas: {}".format(len(areas), areas))
          logger.debug(
              "{:.2f}% valid anchors".format(
                  100.0
                  * np.count_nonzero(inside_filter)
                  / inside_filter.shape[0]
              )
          )
          logger.debug(
              """
  {} anchors with X_min negative.
  {} anchors with Y_min negative.
  {} anchors with X_max above limit.
  {} anchors with Y_max above limit.
          """.format(
                  np.count_nonzero(x_negative),
                  np.count_nonzero(y_negative),
                  np.count_nonzero(x_outof),
                  np.count_nonzero(y_outof),
              )
          )
  
      moved_anchors = anchors.copy()
      min_x = -x_min.min()
      min_y = -y_min.min()
  
      moved_anchors += [[min_x, min_y, min_x, min_y]]
  
      max_x = int(moved_anchors[:, 2].max())
      max_y = int(moved_anchors[:, 3].max())
  
      image_pil, _ = get_image_draw(image)
      back = Image.new("RGB", [max_x, max_y], "white")
      back.paste(image_pil, [int(min_x), int(min_y)])
  
      draw = ImageDraw.Draw(back, "RGBA")
  
      anchor_id_to_draw = anchor_num
      draw_every = pred_dict["anchor_reference"].shape[0]
      first = True
      for anchor_id, anchor in enumerate(moved_anchors):
          if anchor_num is not None:
              if anchor_id != anchor_id_to_draw:
                  continue
              else:
                  anchor_id_to_draw += draw_every
  
          if first and anchor_num is not None:
              draw.rectangle(
                  list(anchor),
                  fill=(255, 0, 0, 40),
                  outline=(0, 255, 0, 120),
              )
              first = False
          elif anchor_num is None:
              draw.rectangle(
                  list(anchor),
                  fill=(255, 0, 0, 1),
                  outline=(0, 255, 0, 2),
              )
          else:
              draw.rectangle(
                  list(anchor),
                  fill=(255, 0, 0, 2),
                  outline=(0, 255, 0, 4),
              )
  
      draw.text(
          tuple([min_x, min_y - 10]),
          text="{}w x {}h".format(width, height),
          font=font,
          fill=(0, 0, 0, 160),
      )
  
      return back
  
imports: import io
  import numpy
  import os
  import logging
  import PIL.Image
  import PIL.ImageDraw
  import PIL.ImageFont
  import tensorflow
  from .bbox_overlap import bbox_overlap
  from .bbox_transform import decode
  from base64 import b64encode
  from sys import stdout
label_desc: Use image node_id 11 for calling a global function with example usage: draw_anchors(pred_dict, image, anchor_num) and returns: back