code: def test_save_sprite(rng):
      """Test covers _save_sprite as well as _bytesIO_to_base64."""
      # Generate a simulated volume with a square inside
      data = rng.uniform(size=140).reshape(7, 5, 4)
      mask = np.zeros((7, 5, 4), dtype=int)
      mask[1:-1, 1:-1, 1:-1] = 1
      # Save the sprite using BytesIO
      sprite_io = BytesIO()
      html_stat_map._save_sprite(
          data, sprite_io, vmin=0, vmax=1, mask=mask, format="png"
      )
  
      # Load the sprite back in base64
      sprite_base64 = html_stat_map._bytesIO_to_base64(sprite_io)
  
      decoded_io = BytesIO()
      decoded_io.write(base64.b64decode(sprite_base64))
      decoded_io.seek(0)
      img = plt.imread(decoded_io, format="png")
      correct_img = np.ma.array(
          html_stat_map._data_to_sprite(data),
          mask=html_stat_map._data_to_sprite(mask),
      )
      correct_img = plt.Normalize(0, 1)(correct_img)
      cmapped = plt.get_cmap("Greys")(correct_img)
      assert np.allclose(img, cmapped, atol=0.1)
  
imports: import base64
  import warnings
  from io import BytesIO
  import numpy
  import pytest
  from matplotlib import pyplot
  from nibabel import Nifti1Image
  from nilearn import datasets, image
  from nilearn.image import get_data, new_img_like
  from nilearn.plotting import html_stat_map
  from ..js_plotting_utils import colorscale
label_desc: Use image node_id 6 for calling a global function with example usage: test_save_sprite(rng) without return types