code: def image_comparison(
      baseline_images,
      extensions=None,
      tol=0,
      freetype_version=None,
      remove_text=False,
      savefig_kwarg=None,
      # Default of mpl_test_settings fixture and cleanup too.
      style=("classic", "_classic_test_patch"),
  ):
      """
      Compare images generated by the test with those specified in
      *baseline_images*, which must correspond, else an `ImageComparisonFailure`
      exception will be raised.
  
      Parameters
      ----------
      baseline_images : list or None
          A list of strings specifying the names of the images generated by
          calls to `.Figure.savefig`.
  
          If *None*, the test function must use the ``baseline_images`` fixture,
          either as a parameter or with `pytest.mark.usefixtures`. This value is
          only allowed when using pytest.
  
      extensions : None or list of str
          The list of extensions to test, e.g. ``['png', 'pdf']``.
  
          If *None*, defaults to all supported extensions: png, pdf, and svg.
  
          When testing a single extension, it can be directly included in the
          names passed to *baseline_images*.  In that case, *extensions* must not
          be set.
  
          In order to keep the size of the test suite from ballooning, we only
          include the ``svg`` or ``pdf`` outputs if the test is explicitly
          exercising a feature dependent on that backend (see also the
          `check_figures_equal` decorator for that purpose).
  
      tol : float, default: 0
          The RMS threshold above which the test is considered failed.
  
          Due to expected small differences in floating-point calculations, on
          32-bit systems an additional 0.06 is added to this threshold.
  
      freetype_version : str or tuple
          The expected freetype version or range of versions for this test to
          pass.
  
      remove_text : bool
          Remove the title and tick text from the figure before comparison.  This
          is useful to make the baseline images independent of variations in text
          rendering between different versions of FreeType.
  
          This does not remove other, more deliberate, text, such as legends and
          annotations.
  
      savefig_kwarg : dict
          Optional arguments that are passed to the savefig method.
  
      style : str, dict, or list
          The optional style(s) to apply to the image test. The test itself
          can also apply additional styles if desired. Defaults to ``["classic",
          "_classic_test_patch"]``.
      """
  
      if baseline_images is not None:
          # List of non-empty filename extensions.
          baseline_exts = [
              *filter(
                  None,
                  {
                      Path(baseline).suffix[1:]
                      for baseline in baseline_images
                  },
              )
          ]
          if baseline_exts:
              if extensions is not None:
                  raise ValueError(
                      "When including extensions directly in 'baseline_images', "
                      "'extensions' cannot be set as well"
                  )
              if len(baseline_exts) > 1:
                  raise ValueError(
                      "When including extensions directly in 'baseline_images', "
                      "all baselines must share the same suffix"
                  )
              extensions = baseline_exts
              baseline_images = (
                  [  # Chop suffix out from baseline_images.
                      Path(baseline).stem
                      for baseline in baseline_images
                  ]
              )
      if extensions is None:
          # Default extensions to test, if not set via baseline_images.
          extensions = ["png", "pdf", "svg"]
      if savefig_kwarg is None:
          savefig_kwarg = dict()  # default no kwargs to savefig
      if sys.maxsize <= 2**32:
          tol += 0.06
      return _pytest_image_comparison(
          baseline_images=baseline_images,
          extensions=extensions,
          tol=tol,
          freetype_version=freetype_version,
          remove_text=remove_text,
          savefig_kwargs=savefig_kwarg,
          style=style,
      )
  
imports: import contextlib
  import functools
  import inspect
  import os
  from platform import uname
  from pathlib import Path
  import shutil
  import string
  import sys
  import warnings
  from packaging.version import parse
  import matplotlib.style
  import matplotlib.units
  import matplotlib.testing
  from matplotlib import _pylab_helpers, cbook, ft2font, pyplot, ticker
  from .compare import comparable_formats, compare_images, make_test_filename
  from .exceptions import ImageComparisonFailure
label_desc: Use image node_id 8 for calling a global function with example usage: image_comparison(baseline_images, extensions, tol, freetype_version, remove_text, savefig_kwarg, style) and returns: _pytest_image_comparison