code: def test_save_cmap(cmap, n_colors):
      """Test covers _save_cmap as well as _bytesIO_to_base64."""
      # Save the cmap using BytesIO
      cmap_io = BytesIO()
      html_stat_map._save_cm(
          cmap_io, cmap, format="png", n_colors=n_colors
      )
  
      # Load the colormap back in base64
      cmap_base64 = html_stat_map._bytesIO_to_base64(cmap_io)
  
      decoded_io = BytesIO()
      decoded_io.write(base64.b64decode(cmap_base64))
      decoded_io.seek(0)
      img = plt.imread(decoded_io, format="png")
      expected = plt.get_cmap(cmap)(np.linspace(0, 1, n_colors))
      assert np.allclose(img, expected, 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 7 for calling a global function with example usage: test_save_cmap(cmap, n_colors) without return types