code: def _colorbar_from_array(
      array, vmin, vmax, threshold, symmetric_cbar=True, cmap="cold_hot"
  ):
      """Generate a custom colorbar for an array.
  
      Internal function used by plot_img_on_surf
  
      array : np.ndarray
          Any 3D array.
  
      vmin : float
          lower bound for plotting of stat_map values.
  
      vmax : float
          upper bound for plotting of stat_map values.
  
      threshold : float
          If None is given, the colorbar is not thresholded.
          If a number is given, it is used to threshold the colorbar.
          Absolute values lower than threshold are shown in gray.
  
      kwargs : dict
          Extra arguments passed to get_colorbar_and_data_ranges.
  
      cmap : str, default='cold_hot'
          The name of a matplotlib or nilearn colormap.
  
      """
      _, _, vmin, vmax = get_colorbar_and_data_ranges(
          array,
          vmin=vmin,
          vmax=vmax,
          symmetric_cbar=symmetric_cbar,
      )
      norm = Normalize(vmin=vmin, vmax=vmax)
      cmaplist = [cmap(i) for i in range(cmap.N)]
  
      if threshold is None:
          threshold = 0.0
  
      # set colors to grey for absolute values < threshold
      istart = int(norm(-threshold, clip=True) * (cmap.N - 1))
      istop = int(norm(threshold, clip=True) * (cmap.N - 1))
      for i in range(istart, istop):
          cmaplist[i] = (0.5, 0.5, 0.5, 1.0)
      our_cmap = LinearSegmentedColormap.from_list(
          "Custom cmap", cmaplist, cmap.N
      )
      sm = plt.cm.ScalarMappable(cmap=our_cmap, norm=norm)
  
      # fake up the array of the scalar mappable.
      sm._A = []
  
      return sm
  
imports: import itertools
  import math
  from collections.abc import Sequence
  from warnings import warn
  import matplotlib
  import matplotlib.pyplot
  import numpy
  from matplotlib import gridspec
  from matplotlib.cm import ScalarMappable
  from matplotlib.colorbar import make_axes
  from matplotlib.colors import LinearSegmentedColormap, Normalize, to_rgba
  from matplotlib.patches import Patch
  from mpl_toolkits.mplot3d.art3d import Poly3DCollection
  from nilearn import image, surface
  from nilearn._utils import check_niimg_3d, compare_version, fill_doc
  from nilearn._utils.helpers import is_kaleido_installed, is_plotly_installed
  from nilearn.plotting.cm import cold_hot, mix_colormaps
  from nilearn.plotting.displays._slicers import _get_cbar_ticks
  from nilearn.plotting.html_surface import get_vertexcolor
  from nilearn.plotting.img_plotting import get_colorbar_and_data_ranges
  from nilearn.plotting.js_plotting_utils import colorscale
  from nilearn.surface import load_surf_data, load_surf_mesh, vol_to_surf
  from nilearn.surface.surface import check_mesh
label_desc: Use image node_id 26 for calling a global function with example usage: _colorbar_from_array(array, vmin, vmax, threshold, symmetric_cbar, cmap) and returns: sm