code: def create_thumbnail(
      infile, thumbfile, width=275, height=275, cx=0.5, cy=0.5, border=4
  ):
      baseout, extout = op.splitext(thumbfile)
  
      im = matplotlib.image.imread(infile)
      rows, cols = im.shape[:2]
      x0 = int(cx * cols - 0.5 * width)
      y0 = int(cy * rows - 0.5 * height)
      xslice = slice(x0, x0 + width)
      yslice = slice(y0, y0 + height)
      thumb = im[yslice, xslice]
      thumb[:border, :, :3] = thumb[-border:, :, :3] = 0
      thumb[:, :border, :3] = thumb[:, -border:, :3] = 0
  
      dpi = 100
      fig = plt.figure(figsize=(width / dpi, height / dpi), dpi=dpi)
  
      ax = fig.add_axes(
          [0, 0, 1, 1],
          aspect="auto",
          frameon=False,
          xticks=[],
          yticks=[],
      )
      if all(thumb.shape):
          ax.imshow(
              thumb,
              aspect="auto",
              resample=True,
              interpolation="bilinear",
          )
      else:
          warnings.warn(
              f"Bad thumbnail crop. {thumbfile} will be empty."
          )
      fig.savefig(thumbfile, dpi=dpi)
      return fig
  
imports: import os
  import os.path
  import re
  import glob
  import token
  import tokenize
  import shutil
  import warnings
  import matplotlib
  import matplotlib.pyplot
label_desc: Use image node_id 2 for calling a global function with example usage: create_thumbnail(infile, thumbfile, width, height, cx, cy, border) and returns: fig