code: def assert_image_match(
      im1,
      im2,
      min_corr=0.9,
      px_threshold=50.0,
      px_count=None,
      max_px_diff=None,
      avg_px_diff=None,
      img_diff=None,
  ):
      """Check that two images match.
  
      Images that differ in shape or dtype will fail unconditionally.
      Further tests for similarity depend on the arguments supplied.
  
      Parameters
      ----------
      im1 : (h, w, 4) ndarray
          Test output image
      im2 : (h, w, 4) ndarray
          Test standard image
      min_corr : float or None
          Minimum allowed correlation coefficient between corresponding image
          values (see numpy.corrcoef)
      px_threshold : float
          Minimum value difference at which two pixels are considered different
      px_count : int or None
          Maximum number of pixels that may differ
      max_px_diff : float or None
          Maximum allowed difference between pixels
      avg_px_diff : float or None
          Average allowed difference between pixels
      img_diff : float or None
          Maximum allowed summed difference between images
  
      """
      assert im1.ndim == 3
      assert im1.shape[2] == 4
      assert im1.dtype == im2.dtype
  
      diff = im1.astype(float) - im2.astype(float)
      if img_diff is not None:
          assert np.abs(diff).sum() <= img_diff
  
      pxdiff = diff.max(axis=2)  # largest value difference per pixel
      mask = np.abs(pxdiff) >= px_threshold
      if px_count is not None:
          assert mask.sum() <= px_count
  
      masked_diff = diff[mask]
      if max_px_diff is not None and masked_diff.size > 0:
          assert masked_diff.max() <= max_px_diff
      if avg_px_diff is not None and masked_diff.size > 0:
          assert masked_diff.mean() <= avg_px_diff
  
      if min_corr is not None:
          with np.errstate(invalid="ignore"):
              corr = np.corrcoef(im1.ravel(), im2.ravel())[0, 1]
          assert corr >= min_corr
  
imports: import time
  import os
  import sys
  import inspect
  import base64
  from subprocess import check_call, CalledProcessError
  import numpy
  from http.client import HTTPConnection
  from urllib.parse import urlencode
  from ..None import scene, config
  from ..io import read_png, write_png
  from ..gloo.util import _screenshot
  from ..util import run_subprocess
  from .None import IS_CI
label_desc: Use image node_id 4 for calling a global function with example usage: assert_image_match(im1, im2, min_corr, px_threshold, px_count, max_px_diff, avg_px_diff, img_diff) without return types