code: def pad(
      image: Union[str, Image.Image],
      output_path: Optional[str] = None,
      w_factor: float = 0.25,
      h_factor: float = 0.25,
      color: Tuple[int, int, int] = utils.DEFAULT_COLOR,
      metadata: Optional[List[Dict[str, Any]]] = None,
      bboxes: Optional[List[Tuple]] = None,
      bbox_format: Optional[str] = None,
  ) -> Image.Image:
      """
      Pads the image
  
      @param image: the path to an image or a variable of type PIL.Image.Image
          to be augmented
  
      @param output_path: the path in which the resulting image will be stored.
          If None, the resulting PIL Image will still be returned
  
      @param w_factor: width * w_factor pixels are padded to both left and right
          of the image
  
      @param h_factor: height * h_factor pixels are padded to the top and the
          bottom of the image
  
      @param color: color of the padded border in RGB values
  
      @param metadata: if set to be a list, metadata about the function execution
          including its name, the source & dest width, height, etc. will be appended
          to the inputted list. If set to None, no metadata will be appended or returned
  
      @param bboxes: a list of bounding boxes can be passed in here if desired. If
          provided, this list will be modified in place such that each bounding box is
          transformed according to this function
  
      @param bbox_format: signifies what bounding box format was used in `bboxes`. Must
          specify `bbox_format` if `bboxes` is provided. Supported bbox_format values are
          "pascal_voc", "pascal_voc_norm", "coco", and "yolo"
  
      @returns: the augmented PIL Image
      """
      assert w_factor >= 0, "w_factor cannot be a negative number"
      assert h_factor >= 0, "h_factor cannot be a negative number"
      utils.validate_rgb_color(color)
  
      image = imutils.validate_and_load_image(image)
  
      func_kwargs = imutils.get_func_kwargs(metadata, locals())
      src_mode = image.mode
  
      width, height = image.size
  
      left = right = int(w_factor * width)
      top = bottom = int(h_factor * height)
  
      aug_image = Image.new(
          mode="RGB",
          size=(width + left + right, height + top + bottom),
          color=color,
      )
      aug_image.paste(image, box=(left, top))
  
      imutils.get_metadata(
          metadata=metadata,
          function_name="pad",
          aug_image=aug_image,
          **func_kwargs,
      )
  
      return imutils.ret_and_save_image(
          aug_image, output_path, src_mode
      )
  
imports: import io
  import math
  import os
  import pickle
  from copy import deepcopy
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  from augly import utils
  from augly.image import utils
  from augly.image.utils.bboxes import spatial_bbox_helper
  from PIL import Image, ImageDraw, ImageEnhance, ImageFilter, ImageFont
label_desc: Use image node_id 23 for calling a global function with example usage: pad(image, output_path, w_factor, h_factor, color, metadata, bboxes, bbox_format) and returns: imutils