code: def _make_3d_edges(vertices, is_mask):
      """Create the edges set: Returns a list of edges for a 3D image.
  
      Parameters
      ----------
      vertices : ndarray
          The indices of the voxels.
  
      is_mask : boolean
          If is_mask is true, it returns the mask of edges.
          Returns 1 if the edge is contained in the mask, 0 otherwise.
  
      Returns
      -------
      edges : ndarray
          Edges corresponding to the image or mask.
          shape: (1, n_edges) if_mask,
                 (2, n_edges) otherwise.
  
      """
      if is_mask:
          edges_deep = np.logical_and(
              vertices[:, :, :-1].ravel(), vertices[:, :, 1:].ravel()
          )
          edges_right = np.logical_and(
              vertices[:, :-1].ravel(), vertices[:, 1:].ravel()
          )
          edges_down = np.logical_and(
              vertices[:-1].ravel(), vertices[1:].ravel()
          )
      else:
          edges_deep = np.vstack(
              [vertices[:, :, :-1].ravel(), vertices[:, :, 1:].ravel()]
          )
          edges_right = np.vstack(
              [vertices[:, :-1].ravel(), vertices[:, 1:].ravel()]
          )
          edges_down = np.vstack(
              [vertices[:-1].ravel(), vertices[1:].ravel()]
          )
  
      edges = np.hstack([edges_deep, edges_right, edges_down])
  
      return edges
  
imports: import warnings
  import numpy
  from joblib import Memory
  from nibabel import Nifti1Image
  from scipy.sparse import coo_matrix, csgraph, dia_matrix
  from sklearn.base import BaseEstimator, ClusterMixin, TransformerMixin
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from nilearn._utils import fill_doc
  from nilearn.image import get_data
  from nilearn.masking import unmask_from_to_3d_array
label_desc: Use image node_id 2 for calling a global function with example usage: _make_3d_edges(vertices, is_mask) and returns: edges