code: def animation_compare(
      baseline_images, nframes, fmt=".png", tol=1e-3, remove_text=True
  ):
      def decorator(func):
          @functools.wraps(func)
          def wrapper(*args, **kwargs):
              # First close anything from previous tests
              plt.close("all")
  
              anim = func(*args, **kwargs)
              if remove_text:
                  fignum = plt.get_fignums()[0]
                  fig = plt.figure(fignum)
                  remove_ticks_and_titles(fig)
              try:
                  _compare_animation(
                      anim, baseline_images, fmt, nframes, tol
                  )
              finally:
                  plt.close("all")
  
          return wrapper
  
      return decorator
  
file_path: animatplot/tests/tools.py
imports: import os
  from os.path import join, split
  import functools
  import pytest
  import matplotlib.pyplot
  from matplotlib.animation import FileMovieWriter
  from matplotlib.testing.compare import compare_images
  from matplotlib.testing.decorators import remove_ticks_and_titles
  from matplotlib.testing.exceptions import ImageComparisonFailure
label_desc: Use image node_id 2 for calling a global function with example usage: animation_compare(baseline_images, nframes, fmt, tol, remove_text) and returns: decorator, wrapper