code: def ggplot_equals(plot: ggplot, name: str) -> bool:
      """
      Compare ggplot object to image determined by `right`
  
      Parameters
      ----------
      plot :
          ggplot object
      name :
          Identifier for the test image
  
      This function is meant to monkey patch ggplot.__eq__
      so that tests can use the `assert` statement.
      """
      test_file = inspect.stack()[1][1]
      filenames = make_test_image_filenames(name, test_file)
      # Save the figure before testing whether the original image
      # actually exists. This makes creating new tests much easier,
      # as the result image can afterwards just be copied.
      plot += test_theme
      with _test_cleanup():
          plot.save(filenames.result, verbose=False)
  
      if filenames.baseline.exists():
          shutil.copyfile(filenames.baseline, filenames.expected)
      else:
          # Putting the exception in short function makes for
          #  short pytest error messages
          raise_no_baseline_image(filenames.baseline)
  
      err = compare_images(
          filenames.expected,
          filenames.result,
          TOLERANCE,
          in_decorator=True,
      )
      plot._err = err  # For the pytest error message
      return not err
  
imports: import inspect
  import locale
  import shutil
  import types
  import warnings
  from copy import deepcopy
  from pathlib import Path
  import matplotlib
  import matplotlib.pyplot
  from matplotlib.testing.compare import compare_images
  from plotnine import ggplot, theme
label_desc: Use image node_id 2 for calling a global function with example usage: ggplot_equals(plot, name) and returns: unknown