code: def approx_gradient(f, x, epsilon):
      """
      Approximate the gradient of a function using central finite
      differences
  
      Parameters
      ----------
      f: callable
        The function to differentiate
      x: ndarray
        Point where the function gradient is to be evaluated
      epsilon: float
        Stepsize for finite differences
  
      Returns
      -------
      g: ndarray
        Function gradient at `x`
      """
      n = len(x)
      g = np.zeros(n)
      ei = np.zeros(n)
      for i in range(n):
          ei[i] = 0.5 * epsilon
          g[i] = (f(x + ei) - f(x - ei)) / epsilon
          ei[i] = 0
      return g
  
imports: import numpy
  import scipy.ndimage
  from ...core.image.image_spaces import as_xyz_image, make_xyz_image, xyz_affine
  from ._registration import _joint_histogram
  from .affine import affine_transforms, inverse_affine, subgrid_affine
  from .chain_transform import ChainTransform
  from .optimizer import configure_optimizer
  from .similarity_measures import similarity_measures
label_desc: Use image node_id 5 for calling a global function with example usage: approx_gradient(f, x, epsilon) and returns: g