code: def saveFailedTest(data, expect, filename):
      # concatenate data, expect, and diff into a single image
      ds = data.shape
      es = expect.shape
  
      shape = (
          max(ds[0], es[0]) + 4,
          ds[1] + es[1] + 8 + max(ds[1], es[1]),
          4,
      )
      img = np.empty(shape, dtype=np.ubyte)
      img[..., :3] = 100
      img[..., 3] = 255
  
      img[2 : 2 + ds[0], 2 : 2 + ds[1], : ds[2]] = data
      img[
          2 : 2 + es[0], ds[1] + 4 : ds[1] + 4 + es[1], : es[2]
      ] = expect
  
      diff = makeDiffImage(data, expect)
      img[2 : 2 + diff.shape[0], -diff.shape[1] - 2 : -2] = diff
  
      png = makePng(
          data
      )  # change `img` to `data` to save just the failed image
      directory = os.path.dirname(filename)
      if not os.path.isdir(directory):
          os.makedirs(directory)
      with open(filename + ".png", "wb") as png_file:
          png_file.write(png)
      print(
          "\nImage comparison failed. Test result: %s %s   Expected result: "
          "%s %s" % (data.shape, data.dtype, expect.shape, expect.dtype)
      )
  
imports: import inspect
  import os
  import sys
  import time
  from pathlib import Path
  import numpy
  from pyqtgraph import GraphicsLayoutWidget, ImageItem, TextItem
  from pyqtgraph import functions
  from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
label_desc: Use image node_id 5 for calling a global function with example usage: saveFailedTest(data, expect, filename) without return types