code: def meme_format(
      image: Union[str, Image.Image],
      output_path: Optional[str] = None,
      text: str = "LOL",
      font_file: str = utils.MEME_DEFAULT_FONT,
      opacity: float = 1.0,
      text_color: Tuple[int, int, int] = utils.DEFAULT_COLOR,
      caption_height: int = 250,
      meme_bg_color: Tuple[int, int, int] = utils.WHITE_RGB_COLOR,
      metadata: Optional[List[Dict[str, Any]]] = None,
      bboxes: Optional[List[Tuple]] = None,
      bbox_format: Optional[str] = None,
  ) -> Image.Image:
      """
      Creates a new image that looks like a meme, given text and an 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 text: the text to be overlaid/used in the meme. note: if using a very
          long string, please add in newline characters such that the text remains
          in a readable font size.
  
      @param font_file: iopath uri to a .ttf font file
  
      @param opacity: the lower the opacity, the more transparent the text
  
      @param text_color: color of the text in RGB values
  
      @param caption_height: the height of the meme caption
  
      @param meme_bg_color: background color of the meme caption 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 isinstance(
          text, str
      ), "Expected variable `text` to be a string"
      assert (
          0.0 <= opacity <= 1.0
      ), "Opacity must be a value in the range [0.0, 1.0]"
      assert (
          caption_height > 10
      ), "Caption height must be greater than 10"
  
      utils.validate_rgb_color(text_color)
      utils.validate_rgb_color(meme_bg_color)
  
      image = imutils.validate_and_load_image(image)
      func_kwargs = imutils.get_func_kwargs(metadata, locals())
      src_mode = image.mode
  
      width, height = image.size
  
      local_font_path = utils.pathmgr.get_local_path(font_file)
      font_size = caption_height - 10
  
      meme = Image.new(
          "RGB", (width, height + caption_height), meme_bg_color
      )
      meme.paste(image, (0, caption_height))
      draw = ImageDraw.Draw(meme)
  
      x_pos, y_pos = 5, 5
      ascender_adjustment = 40
      while True:
          font = ImageFont.truetype(local_font_path, font_size)
          text_bbox = draw.multiline_textbbox(
              (x_pos, y_pos),
              text,
              # pyre-fixme[6]: Expected `Optional[ImageFont._Font]` for 3rd param but got
              #  `FreeTypeFont`.
              font=font,
              anchor="la",
              align="center",
          )
  
          text_width, text_height = (
              text_bbox[2] - text_bbox[0],
              text_bbox[3] - text_bbox[1],
          )
  
          x_pos = round((width - text_width) / 2)
          y_pos = (
              round((caption_height - text_height) / 2)
              - ascender_adjustment
          )
  
          if text_width <= (width - 10) and text_height <= (
              caption_height - 10
          ):
              break
  
          font_size -= 5
  
      draw.multiline_text(
          (x_pos, y_pos),
          text,
          # pyre-fixme[6]: Expected `Optional[ImageFont._Font]` for 3rd param but got
          #  `FreeTypeFont`.
          font=font,
          anchor="la",
          fill=(
              text_color[0],
              text_color[1],
              text_color[2],
              round(opacity * 255),
          ),
          align="center",
      )
  
      imutils.get_metadata(
          metadata=metadata,
          function_name="meme_format",
          aug_image=meme,
          **func_kwargs,
      )
  
      return imutils.ret_and_save_image(meme, 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 15 for calling a global function with example usage: meme_format(image, output_path, text, font_file, opacity, text_color, caption_height, meme_bg_color, metadata, bboxes, bbox_format) and returns: imutils