code: def _compute_facecolors_matplotlib(
      bg_map, faces, n_vertices, darkness, alpha
  ):
      """Help for plot_surf with matplotlib engine.
  
      This function computes the facecolors.
      """
      if bg_map is None:
          bg_data = np.ones(n_vertices) * 0.5
      else:
          bg_data = np.copy(load_surf_data(bg_map))
          if bg_data.shape[0] != n_vertices:
              raise ValueError(
                  "The bg_map does not have the same number "
                  "of vertices as the mesh."
              )
  
      bg_faces = np.mean(bg_data[faces], axis=1)
      # scale background map if need be
      bg_vmin, bg_vmax = np.min(bg_faces), np.max(bg_faces)
      if bg_vmin < 0 or bg_vmax > 1:
          bg_norm = mpl.colors.Normalize(vmin=bg_vmin, vmax=bg_vmax)
          bg_faces = bg_norm(bg_faces)
  
      if darkness is not None:
          bg_faces *= darkness
          warn(
              (
                  "The `darkness` parameter will be deprecated in release 0.13. "
                  "We recommend setting `darkness` to None"
              ),
              DeprecationWarning,
          )
  
      face_colors = plt.cm.gray_r(bg_faces)
  
      # set alpha if in auto mode
      if alpha == "auto":
          alpha = 0.5 if bg_map is None else 1
      # modify alpha values of background
      face_colors[:, 3] = alpha * face_colors[:, 3]
  
      return face_colors
  
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 12 for calling a global function with example usage: _compute_facecolors_matplotlib(bg_map, faces, n_vertices, darkness, alpha) and returns: face_colors