code: def make_gif(paths, gif_path, max_frame=50, prefix=""):
      import imageio
  
      paths.sort()
  
      skip_frame = len(paths) // max_frame
      paths = paths[::skip_frame]
  
      images = [imageio.imread(path) for path in paths]
      max_h, max_w, max_c = np.max(
          np.array([image.shape for image in images]), 0
      )
  
      for idx, image in enumerate(images):
          h, w, c = image.shape
          blank = np.ones([max_h, max_w, max_c], dtype=np.uint8) * 255
  
          pivot_h, pivot_w = (max_h - h) // 2, (max_w - w) // 2
          blank[
              pivot_h : pivot_h + h, pivot_w : pivot_w + w, :c
          ] = image
  
          images[idx] = blank
  
      try:
          images = [Image.fromarray(image) for image in images]
          draws = [ImageDraw.Draw(image) for image in images]
          font = ImageFont.truetype("assets/arial.ttf", 30)
  
          steps = [
              int(
                  os.path.basename(path).rsplit(".", 1)[0].split("-")[1]
              )
              for path in paths
          ]
          for step, draw in zip(steps, draws):
              draw.text(
                  (max_h // 20, max_h // 20),
                  f"{prefix}step: {format(step, ',d')}",
                  (0, 0, 0),
                  font=font,
              )
      except IndexError:
          pass
  
      imageio.mimsave(
          gif_path, [np.array(img) for img in images], duration=0.5
      )
  
imports: from __future__ import print_function
  from collections import defaultdict
  import collections
  from datetime import datetime
  import os
  import json
  import logging
  import numpy
  import pygraphviz
  import torch
  from torch.autograd import Variable
  from PIL import Image
  from PIL import ImageFont
  from PIL import ImageDraw
label_desc: Use image node_id 3 for calling a global function with example usage: make_gif(paths, gif_path, max_frame, prefix) without return types