code: def assert_image_similar(a, b, epsilon, msg=None):
      assert a.mode == b.mode, (
          msg or f"got mode {repr(a.mode)}, expected {repr(b.mode)}"
      )
      assert a.size == b.size, (
          msg or f"got size {repr(a.size)}, expected {repr(b.size)}"
      )
  
      a, b = convert_to_comparable(a, b)
  
      diff = 0
      for ach, bch in zip(a.split(), b.split()):
          chdiff = ImageMath.eval("abs(a - b)", a=ach, b=bch).convert(
              "L"
          )
          diff += sum(
              i * num for i, num in enumerate(chdiff.histogram())
          )
  
      ave_diff = diff / (a.size[0] * a.size[1])
      try:
          assert epsilon >= ave_diff, (
              (msg or "")
              + f" average pixel value difference {ave_diff:.4f} > epsilon {epsilon:.4f}"
          )
      except Exception as e:
          if HAS_UPLOADER:
              try:
                  url = test_image_results.upload(a, b)
                  logger.error(f"Url for test images: {url}")
              except Exception:
                  pass
          raise e
  
imports: import logging
  import os
  import shutil
  import sys
  import sysconfig
  import tempfile
  from io import BytesIO
  import pytest
  from packaging.version import parse
  from PIL import Image, ImageMath, features
label_desc: Use image node_id 6 for calling a global function with example usage: assert_image_similar(a, b, epsilon, msg) without return types