code: def _compute_weights_3d(data, spacing, beta=130, eps=1.0e-6):
      # Weight calculation is main difference in multispectral version
      # Original gradient**2 replaced with sum of gradients ** 2
      gradients = 0
      for channel in range(0, data.shape[-1]):
          gradients += (
              _compute_gradients_3d(data[..., channel], spacing) ** 2
          )
      # All channels considered together in this standard deviation
      beta /= 10 * data.std()
      gradients *= beta
      weights = np.exp(-gradients)
      weights += eps
      return weights
  
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 2 for calling a global function with example usage: _compute_weights_3d(data, spacing, beta, eps) and returns: weights