code: def _compute_gradients_3d(data, spacing):
      gr_deep = (
          np.abs(data[:, :, :-1] - data[:, :, 1:]).ravel() / spacing[2]
      )
      gr_right = np.abs(data[:, :-1] - data[:, 1:]).ravel() / spacing[1]
      gr_down = np.abs(data[:-1] - data[1:]).ravel() / spacing[0]
      return np.r_[gr_deep, gr_right, gr_down]
  
file_path: nilearn/nilearn/_utils/segmentation.py
imports: import warnings
  import numpy
  from scipy import ndimage, sparse
  from scipy.sparse.linalg import cg
  from sklearn.utils import as_float_array
label_desc: Use image node_id 3 for calling a global function with example usage: _compute_gradients_3d(data, spacing) and returns: np