code: def overlay(
      video_path: str,
      overlay_path: str,
      output_path: Optional[str] = None,
      overlay_size: Optional[float] = None,
      x_factor: float = 0.0,
      y_factor: float = 0.0,
      use_overlay_audio: bool = False,
      metadata: Optional[List[Dict[str, Any]]] = None,
  ) -> str:
      """
      Overlays media onto the video at position (width * x_factor, height * y_factor)
  
      @param video_path: the path to the video to be augmented
  
      @param overlay_path: the path to the media (image or video) that will be
          overlaid onto the video
  
      @param output_path: the path in which the resulting video will be stored.
          If not passed in, the original video file will be overwritten
  
      @param overlay_size: size of the overlaid media with respect to the background
          video. If set to None, the original size of the overlaid media is used
  
      @param x_factor: specifies where the left side of the overlaid media should be
          placed, relative to the video width
  
      @param y_factor: specifies where the top side of the overlaid media should be
          placed, relative to the video height
  
      @param use_overlay_audio: if set to True and the media type is a video, the audio
          of the overlaid video will be used instead of the main/background video's audio
  
      @param metadata: if set to be a list, metadata about the function execution
          including its name, the source & dest duration, fps, etc. will be appended
          to the inputted list. If set to None, no metadata will be appended or returned
  
      @returns: the path to the augmented video
      """
      func_kwargs = helpers.get_func_kwargs(
          metadata, locals(), video_path
      )
      local_path = utils.pathmgr.get_local_path(video_path)
  
      overlay_path = utils.pathmgr.get_local_path(overlay_path)
      tmp_overlay_path = None
      if overlay_size is not None:
          assert (
              0 < overlay_size <= 1
          ), "overlay_size must be a value in the range (0, 1]"
  
          video_info = helpers.get_video_info(local_path)
          overlay_h = int(video_info["height"] * overlay_size)
          overlay_w = int(video_info["width"] * overlay_size)
  
          _, tmp_overlay_path = tempfile.mkstemp(
              suffix=os.path.splitext(overlay_path)[1]
          )
  
          if utils.is_image_file(overlay_path):
              imaugs.resize(
                  overlay_path, tmp_overlay_path, overlay_w, overlay_h
              )
          else:
              resize(
                  overlay_path, tmp_overlay_path, overlay_h, overlay_w
              )
  
      overlay_aug = af.VideoAugmenterByOverlay(
          tmp_overlay_path or overlay_path,
          x_factor,
          y_factor,
          use_overlay_audio,
      )
      overlay_aug.add_augmenter(local_path, output_path)
  
      if tmp_overlay_path:
          os.remove(tmp_overlay_path)
  
      if metadata is not None:
          helpers.get_metadata(
              metadata=metadata, function_name="overlay", **func_kwargs
          )
  
      return output_path or video_path
  
imports: import functools
  import math
  import os
  import shutil
  import tempfile
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  from augly import audio, image, utils
  from augly.audio import utils
  from augly.video import helpers, utils
  from augly.video.augmenters import cv2, ffmpeg
label_desc: Use image node_id 24 for calling a global function with example usage: overlay(video_path, overlay_path, output_path, overlay_size, x_factor, y_factor, use_overlay_audio, metadata) and returns: unknown