code: def load_surf_mesh(surf_mesh):
      """Load a surface :term:`mesh` geometry.
  
      Parameters
      ----------
      surf_mesh : :obj:`str`, :obj:`pathlib.Path`, or \
          :obj:`numpy.ndarray` or Mesh
          Either a file containing surface :term:`mesh` geometry
          (valid formats are .gii .gii.gz or Freesurfer specific files
          such as .orig, .pial, .sphere, .white, .inflated)
          or two Numpy arrays organized in a list,
          tuple or a namedtuple with the fields "coordinates" and "faces",
          or a Mesh object with "coordinates" and "faces" attributes.
  
      Returns
      -------
      mesh : Mesh
          With the fields "coordinates" and "faces", each containing a
          :obj:`numpy.ndarray`
  
      """
      # if input is a filename, try to load it
      surf_mesh = stringify_path(surf_mesh)
      if isinstance(surf_mesh, str):
          # resolve globbing
          file_list = resolve_globbing(surf_mesh)
          if len(file_list) == 1:
              surf_mesh = file_list[0]
          elif len(file_list) > 1:
              # empty list is handled inside resolve_globbing function
              raise ValueError(
                  f"More than one file matching path: {surf_mesh} \n"
                  "load_surf_mesh can only load one file at a time."
              )
  
          if any(
              surf_mesh.endswith(x) for x in FREESURFER_MESH_EXTENSIONS
          ):
              coords, faces, header = fs.io.read_geometry(
                  surf_mesh, read_metadata=True
              )
              # See https://github.com/nilearn/nilearn/pull/3235
              if "cras" in header:
                  coords += header["cras"]
              mesh = Mesh(coordinates=coords, faces=faces)
          elif surf_mesh.endswith("gii"):
              coords, faces = _gifti_img_to_mesh(
                  nibabel.load(surf_mesh)
              )
              mesh = Mesh(coordinates=coords, faces=faces)
          elif surf_mesh.endswith("gii.gz"):
              gifti_img = _load_surf_files_gifti_gzip(surf_mesh)
              coords, faces = _gifti_img_to_mesh(gifti_img)
              mesh = Mesh(coordinates=coords, faces=faces)
          else:
              raise ValueError(
                  "The input type is not recognized. "
                  f"{surf_mesh!r} was given "
                  "while valid inputs are one of the following "
                  "file formats: .gii, .gii.gz, "
                  "Freesurfer specific files such as "
                  f"{_stringify(FREESURFER_MESH_EXTENSIONS)}, "
                  "two Numpy arrays organized in a list, tuple "
                  "or a namedtuple with the "
                  'fields "coordinates" and "faces".'
              )
      elif isinstance(surf_mesh, (list, tuple)):
          try:
              coords, faces = surf_mesh
              mesh = Mesh(coordinates=coords, faces=faces)
          except Exception:
              raise ValueError(
                  "If a list or tuple is given as input, "
                  "it must have two elements, the first is "
                  "a Numpy array containing the x-y-z coordinates "
                  "of the mesh vertices, the second is a Numpy "
                  "array containing  the indices (into coords) of "
                  "the mesh faces. The input was a list with "
                  f"{len(surf_mesh)} elements."
              )
      elif hasattr(surf_mesh, "faces") and hasattr(
          surf_mesh, "coordinates"
      ):
          coords, faces = surf_mesh.coordinates, surf_mesh.faces
          mesh = Mesh(coordinates=coords, faces=faces)
  
      else:
          raise ValueError(
              "The input type is not recognized. "
              "Valid inputs are one of the following file "
              "formats: .gii, .gii.gz, "
              "Freesurfer specific files such as "
              f"{_stringify(FREESURFER_MESH_EXTENSIONS)}"
              "or two Numpy arrays organized in a list, tuple or "
              'a namedtuple with the fields "coordinates" and '
              '"faces"'
          )
  
      return mesh
  
imports: import gzip
  import os
  import warnings
  from collections import namedtuple
  from collections.abc import Mapping
  import nibabel
  import numpy
  import sklearn.cluster
  import sklearn.preprocessing
  from nibabel import freesurfer, gifti
  from scipy import interpolate, sparse
  from nilearn import _utils, datasets
  from nilearn._utils import stringify_path
  from nilearn._utils.path_finding import resolve_globbing
  from nilearn.image import get_data, load_img, resampling
label_desc: Use image node_id 21 for calling a global function with example usage: load_surf_mesh(surf_mesh) and returns: mesh