code: def _draw_label(
      img: np.ndarray,
      caption: str,
      x: int,
      y: int,
      color: Union[np.ndarray, list, tuple],
      border_color: Union[np.ndarray, list, tuple],
      font_path=DEFAULT_FONT_PATH,
      font_size: int = 20,
      return_as_pil_img: bool = False,
      pad_width_factor=0.02,
      pad_height_factor=0.005,
      thin_border=True,
  ) -> Union[PIL.Image.Image, np.ndarray]:
      """Draw labels on the image"""
      font = PIL.ImageFont.truetype(font_path, size=font_size)
      color = as_rgb_tuple(color)
      border_color = as_rgb_tuple(border_color)
  
      height, width = img.shape[:2]
      x_pad = height * pad_width_factor
      y_pad = width * pad_height_factor
      x, y = x + x_pad, y + y_pad
  
      img = PIL.Image.fromarray(img)
      draw = ImageDraw.Draw(img)
  
      if thin_border is not None:
          # Draw thin / thick border around text
          draw.text(
              (x - 1, y if thin_border else y - 1),
              caption,
              font=font,
              fill=border_color,
          )
          draw.text(
              (x + 1, y if thin_border else y - 1),
              caption,
              font=font,
              fill=border_color,
          )
          draw.text(
              (x if thin_border else x - 1, y - 1),
              caption,
              font=font,
              fill=border_color,
          )
          draw.text(
              (x if thin_border else x + 1, y + 1),
              caption,
              font=font,
              fill=border_color,
          )
  
      # Now draw text over the border
      draw.text((x, y), caption, font=font, fill=color)
      if return_as_pil_img:
          return img
      else:
          return np.array(img)
  
file_path: icevision/icevision/visualize/draw_data.py
imports: from icevision.imports import *
  from icevision.data import *
  from icevision.core import *
  from icevision.visualize.utils import *
  from matplotlib.colors import LinearSegmentedColormap
  from PIL import Image, ImageFont, ImageDraw
  import PIL
label_desc: Use image node_id 3 for calling a global function with example usage: _draw_label(img, caption, x, y, color, border_color, font_path, font_size, return_as_pil_img, pad_width_factor, pad_height_factor, thin_border) and returns: img, np