code: def test_save_figures(gallery_conf):
      """Test file naming when saving figures. Requires mayavi."""
      try:
          from mayavi import mlab
      except ImportError:
          raise pytest.skip("Mayavi not installed")
      mlab.options.offscreen = True
  
      gallery_conf.update(find_mayavi_figures=True)
  
      mlab.test_plot3d()
      plt.plot(1, 1)
      fname_template = os.path.join(
          gallery_conf["gallery_dir"], "image{0}.png"
      )
      image_rst, fig_num = sg.save_figures(
          fname_template, 0, gallery_conf
      )
      assert fig_num == 2
      assert "/image1.png" in image_rst
      assert "/image2.png" in image_rst
  
      mlab.test_plot3d()
      plt.plot(1, 1)
      image_rst, fig_num = sg.save_figures(
          fname_template, 2, gallery_conf
      )
      assert fig_num == 2
      assert "/image2.png" not in image_rst
      assert "/image3.png" in image_rst
      assert "/image4.png" in image_rst
  
      shutil.rmtree(gallery_conf["gallery_dir"])
  
imports: from __future__ import division, absolute_import, print_function, unicode_literals
  import ast
  import codecs
  import copy
  import logging
  import tempfile
  import re
  import os
  import shutil
  import zipfile
  import pytest
  import sphinx_gallery.gen_rst
  from sphinx_gallery import gen_gallery, downloads
  from sphinx_gallery.gen_gallery import generate_dir_rst
  from sphinx_gallery import sphinx_compatibility
  import matplotlib.pyplot
label_desc: Use image node_id 12 for calling a global function with example usage: test_save_figures(gallery_conf) without return types