code: def test_plot_surf_stat_map(engine, rng):
      if not is_plotly_installed() and engine == "plotly":
          pytest.skip(
              "Plotly is not installed; required for this test."
          )
      mesh = generate_surf()
      bg = rng.standard_normal(size=mesh[0].shape[0])
      data = 10 * rng.standard_normal(size=mesh[0].shape[0])
  
      # Plot mesh with stat map
      plot_surf_stat_map(mesh, stat_map=data, engine=engine)
      plot_surf_stat_map(
          mesh, stat_map=data, colorbar=True, engine=engine
      )
      plot_surf_stat_map(mesh, stat_map=data, alpha=1, engine=engine)
  
      # Plot mesh with background and stat map
      plot_surf_stat_map(mesh, stat_map=data, bg_map=bg, engine=engine)
      plot_surf_stat_map(
          mesh,
          stat_map=data,
          bg_map=bg,
          bg_on_data=True,
          darkness=0.5,
          engine=engine,
      )
      plot_surf_stat_map(
          mesh,
          stat_map=data,
          bg_map=bg,
          colorbar=True,
          bg_on_data=True,
          darkness=0.5,
          engine=engine,
      )
  
      # Plot with title
      display = plot_surf_stat_map(
          mesh, stat_map=data, bg_map=bg, title="Stat map title"
      )
      assert display.axes[0].title._text == "Stat map title"
  
      # Apply threshold
      plot_surf_stat_map(
          mesh,
          stat_map=data,
          bg_map=bg,
          bg_on_data=True,
          darkness=0.5,
          threshold=0.3,
          engine=engine,
      )
      plot_surf_stat_map(
          mesh,
          stat_map=data,
          bg_map=bg,
          colorbar=True,
          bg_on_data=True,
          darkness=0.5,
          threshold=0.3,
          engine=engine,
      )
  
      # Change colorbar tick format
      plot_surf_stat_map(
          mesh,
          stat_map=data,
          bg_map=bg,
          colorbar=True,
          bg_on_data=True,
          darkness=0.5,
          cbar_tick_format="%.2g",
          engine=engine,
      )
  
      # Change vmax
      plot_surf_stat_map(mesh, stat_map=data, vmax=5, engine=engine)
      plot_surf_stat_map(
          mesh, stat_map=data, vmax=5, colorbar=True, engine=engine
      )
  
      # Change colormap
      plot_surf_stat_map(
          mesh, stat_map=data, cmap="cubehelix", engine=engine
      )
      plot_surf_stat_map(
          mesh,
          stat_map=data,
          cmap="cubehelix",
          colorbar=True,
          engine=engine,
      )
  
      plt.close()
  
imports: import re
  import tempfile
  import unittest.mock
  import matplotlib.pyplot
  import numpy
  import pytest
  from matplotlib.figure import Figure
  from numpy.testing import assert_array_equal
  from nilearn._utils.helpers import is_kaleido_installed, is_plotly_installed
  from nilearn.conftest import _rng
  from nilearn.datasets import fetch_surf_fsaverage
  from nilearn.plotting.displays import PlotlySurfaceFigure
  from nilearn.plotting.surf_plotting import VALID_HEMISPHERES, VALID_VIEWS, _compute_facecolors_matplotlib, _get_ticks_matplotlib, _get_view_plot_surf_matplotlib, _get_view_plot_surf_plotly, plot_img_on_surf, plot_surf, plot_surf_contours, plot_surf_roi, plot_surf_stat_map
  from nilearn.surface import load_surf_data, load_surf_mesh
  from nilearn.surface.tests._testing import generate_surf
label_desc: Use image node_id 22 for calling a global function with example usage: test_plot_surf_stat_map(engine, rng) without return types