code: def assert_image_approved(
      image, standard_file, message=None, **kwargs
  ):
      """Check that an image test result matches a pre-approved standard.
  
      If the result does not match, then the user can optionally invoke a GUI
      to compare the images and decide whether to fail the test or save the new
      image as the standard.
  
      This function will automatically clone the test-data repository into
      ~/.vispy/test-data. However, it is up to the user to ensure this repository
      is kept up to date and to commit/push new images after they are saved.
  
      Run the test with python <test-path> --vispy-audit-tests to bring up
      the auditing GUI.
  
      Parameters
      ----------
      image : (h, w, 4) ndarray or 'screenshot'
          The test result to check
      standard_file : str
          The name of the approved test image to check against. This file name
          is relative to the root of the vispy test-data repository and will
          be automatically fetched.
      message : str
          A string description of the image. It is recommended to describe
          specific features that an auditor should look for when deciding whether
          to fail a test.
  
      Extra keyword arguments are used to set the thresholds for automatic image
      comparison (see ``assert_image_match()``).
      """
      if isinstance(image, str) and image == "screenshot":
          image = _screenshot(alpha=True)
      if message is None:
          code = inspect.currentframe().f_back.f_code
          message = "%s::%s" % (code.co_filename, code.co_name)
  
      # Make sure we have a test data repo available, possibly invoking git
      data_path = get_test_data_repo()
  
      # Read the standard image if it exists
      std_file = os.path.join(data_path, standard_file)
      if not os.path.isfile(std_file):
          std_image = None
      else:
          std_image = read_png(std_file)
  
      # If the test image does not match, then we go to audit if requested.
      try:
          if image.shape != std_image.shape:
              # Allow im1 to be an integer multiple larger than im2 to account
              # for high-resolution displays
              ims1 = np.array(image.shape).astype(float)
              ims2 = np.array(std_image.shape).astype(float)
              sr = ims1 / ims2
              if (
                  sr[0] != sr[1]
                  or not np.allclose(sr, np.round(sr))
                  or sr[0] < 1
              ):
                  raise TypeError(
                      "Test result shape %s is not an integer factor"
                      " larger than standard image shape %s."
                      % (ims1, ims2)
                  )
              sr = np.round(sr).astype(int)
              image = downsample(image, sr[0], axis=(0, 1)).astype(
                  image.dtype
              )
  
          assert_image_match(image, std_image, **kwargs)
      except Exception:
          if standard_file in git_status(data_path):
              print(
                  "\n\nWARNING: unit test failed against modified standard "
                  "image %s.\nTo revert this file, run `cd %s; git checkout "
                  "%s`\n" % (std_file, data_path, standard_file)
              )
          if config["audit_tests"]:
              sys.excepthook(*sys.exc_info())
              _get_tester().test(image, std_image, message)
              std_path = os.path.dirname(std_file)
              print('Saving new standard image to "%s"' % std_file)
              if not os.path.isdir(std_path):
                  os.makedirs(std_path)
              write_png(std_file, image)
          else:
              if std_image is None:
                  raise Exception(
                      "Test standard %s does not exist." % std_file
                  )
              else:
                  if IS_CI:
                      _save_failed_test(image, std_image, standard_file)
                  raise
  
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 2 for calling a global function with example usage: assert_image_approved(image, standard_file, message) without return types