code: def test_cubic_spline():
      # Cubic spline as defined in [Mattes03] eq. (3)
      #
      # [Mattes03] Mattes, D., Haynor, D. R., Vesselle, H., Lewellen, T. K.,
      #            & Eubank, W. PET-CT image registration in the chest using
      #            free-form deformations. IEEE Transactions on Medical Imaging,
      #            22(1), 120-8, 2003.
      in_list = []
      expected = []
      for epsilon in [-1e-9, 0.0, 1e-9]:
          for t in [-2.0, -1.0, 0.0, 1.0, 2.0]:
              x = t + epsilon
              in_list.append(x)
              absx = np.abs(x)
              sqrx = x * x
              if absx < 1:
                  expected.append(
                      (4.0 - 6 * sqrx + 3.0 * (absx**3)) / 6.0
                  )
              elif absx < 2:
                  expected.append(((2 - absx) ** 3) / 6.0)
              else:
                  expected.append(0.0)
      actual = cubic_spline(np.array(in_list, dtype=np.float64))
      assert_array_almost_equal(
          actual, np.array(expected, dtype=np.float64)
      )
  
imports: import numpy
  import scipy
  from functools import reduce
  from operator import mul
  from dipy.core.ndindex import ndindex
  from dipy.core.interpolation import interpolate_scalar_2d, interpolate_scalar_3d
  from dipy.data import get_fnames
  from dipy.align import vector_fields
  from dipy.align.transforms import regtransforms
  from dipy.align.parzenhist import ParzenJointHistogram, cubic_spline, cubic_spline_derivative, sample_domain_regular
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_almost_equal, assert_equal, assert_raises
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 2 for calling a global function with example usage: test_cubic_spline() without return types