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_test",
  ):
      """
      Compare images generated by the test with those specified in
      *baseline_images*, which must correspond else an
      ImageComparisonFailure exception will be raised.
  
      Arguments
      ---------
      baseline_images : list or None
          A list of strings specifying the names of the images generated by
          calls to :meth:`matplotlib.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 | list ]
  
          If None, defaults to all supported extensions.
          Otherwise, a list of extensions to test. For example ['png','pdf'].
  
      tol : float, optional, default: 0
          The RMS threshold above which the test is considered failed.
  
      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 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 : string
          Optional name for the base style to apply to the image test. The test
          itself can also apply additional styles if desired. Defaults to the
          '_classic_test' style.
  
      """
      if extensions is None:
          # default extensions to test
          extensions = ["png", "pdf", "svg"]
  
      if savefig_kwarg is None:
          # default no kwargs to savefig
          savefig_kwarg = dict()
  
      if is_called_from_pytest():
          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,
          )
      else:
          if baseline_images is None:
              raise ValueError("baseline_images must be specified")
  
          return ImageComparisonTest(
              baseline_images=baseline_images,
              extensions=extensions,
              tol=tol,
              freetype_version=freetype_version,
              remove_text=remove_text,
              savefig_kwargs=savefig_kwarg,
              style=style,
          )
  
imports: from __future__ import absolute_import, division, print_function
  import six
  import functools
  import inspect
  import os
  import sys
  import shutil
  import warnings
  import unittest
  import matplotlib
  import matplotlib.style
  import matplotlib.units
  import matplotlib.testing
  from matplotlib import cbook
  from matplotlib import ticker
  from matplotlib import pyplot
  from matplotlib import ft2font
  from matplotlib.testing.compare import comparable_formats, compare_images, make_test_filename
  from .None import _copy_metadata, is_called_from_pytest
  from .exceptions import ImageComparisonFailure
label_desc: Use image node_id 12 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, ImageComparisonTest