code: def _hemi_morph(tris, vertices_to, vertices_from, smooth, maps, warn):
      _validate_type(smooth, (str, None, "int-like"), "smoothing steps")
      if len(vertices_from) == 0:
          return sparse.csr_matrix((len(vertices_to), 0))
      e = mesh_edges(tris)
      e.data[e.data == 2] = 1
      n_vertices = e.shape[0]
      e += sparse.eye(n_vertices, format="csr")
      if isinstance(smooth, str):
          _check_option(
              "smooth",
              smooth,
              ("nearest",),
              extra=" when used as a string.",
          )
          mm = _surf_nearest(vertices_from, e).tocsr()
      elif smooth == 0:
          mm = sparse.csc_matrix(
              (
                  np.ones(len(vertices_from)),  # data, indices, indptr
                  vertices_from,
                  np.arange(len(vertices_from) + 1),
              ),
              shape=(e.shape[0], len(vertices_from)),
          ).tocsr()
      else:
          mm, n_missing, n_iter = _surf_upsampling_mat(
              vertices_from, e, smooth
          )
          if n_missing and warn:
              warn_(
                  f"{n_missing}/{e.shape[0]} vertices not included in "
                  "smoothing, consider increasing the number of steps"
              )
          logger.info(f"    {n_iter} smooth iterations done.")
      assert mm.shape == (n_vertices, len(vertices_from))
      if maps is not None:
          mm = maps[vertices_to] * mm
      else:  # to == from
          mm = mm[vertices_to]
      assert mm.shape == (len(vertices_to), len(vertices_from))
      return mm
  
imports: import copy
  import os.path
  import warnings
  import numpy
  from scipy import sparse
  from .fixes import _get_img_fdata
  from .morph_map import read_morph_map
  from .parallel import parallel_func
  from .source_estimate import _BaseSourceEstimate, _BaseSurfaceSourceEstimate, _BaseVolSourceEstimate, _get_ico_tris
  from .source_space._source_space import SourceSpaces, _ensure_src, _grid_interp
  from .surface import _compute_nearest, mesh_edges, read_surface
  from .utils import BunchConst, ProgressBar, _check_fname, _check_option, _custom_lru_cache, _ensure_int, _import_h5io_funcs, _import_nibabel, _validate_type, check_version, fill_doc, get_subjects_dir, logger, use_log_level, verbose, warn
  from .utils import warn
label_desc: Use image node_id 15 for calling a global function with example usage: _hemi_morph(tris, vertices_to, vertices_from, smooth, maps, warn) and returns: mm, sparse