code: def test_Wcons():
      # Construct the 4D kurtosis tensor manually from the crossing fiber kt
      # simulate
      Wfit = np.zeros([3, 3, 3, 3])
  
      # Wxxxx
      Wfit[0, 0, 0, 0] = kt_cross[0]
  
      # Wyyyy
      Wfit[1, 1, 1, 1] = kt_cross[1]
  
      # Wzzzz
      Wfit[2, 2, 2, 2] = kt_cross[2]
  
      # Wxxxy
      Wfit[0, 0, 0, 1] = Wfit[0, 0, 1, 0] = Wfit[0, 1, 0, 0] = kt_cross[
          3
      ]
      Wfit[1, 0, 0, 0] = kt_cross[3]
  
      # Wxxxz
      Wfit[0, 0, 0, 2] = Wfit[0, 0, 2, 0] = Wfit[0, 2, 0, 0] = kt_cross[
          4
      ]
      Wfit[2, 0, 0, 0] = kt_cross[4]
  
      # Wxyyy
      Wfit[0, 1, 1, 1] = Wfit[1, 0, 1, 1] = Wfit[1, 1, 1, 0] = kt_cross[
          5
      ]
      Wfit[1, 1, 0, 1] = kt_cross[5]
  
      # Wxxxz
      Wfit[1, 1, 1, 2] = Wfit[1, 2, 1, 1] = Wfit[2, 1, 1, 1] = kt_cross[
          6
      ]
      Wfit[1, 1, 2, 1] = kt_cross[6]
  
      # Wxzzz
      Wfit[0, 2, 2, 2] = Wfit[2, 2, 2, 0] = Wfit[2, 0, 2, 2] = kt_cross[
          7
      ]
      Wfit[2, 2, 0, 2] = kt_cross[7]
  
      # Wyzzz
      Wfit[1, 2, 2, 2] = Wfit[2, 2, 2, 1] = Wfit[2, 1, 2, 2] = kt_cross[
          8
      ]
      Wfit[2, 2, 1, 2] = kt_cross[8]
  
      # Wxxyy
      Wfit[0, 0, 1, 1] = Wfit[0, 1, 0, 1] = Wfit[0, 1, 1, 0] = kt_cross[
          9
      ]
      Wfit[1, 0, 0, 1] = Wfit[1, 0, 1, 0] = Wfit[1, 1, 0, 0] = kt_cross[
          9
      ]
  
      # Wxxzz
      Wfit[0, 0, 2, 2] = Wfit[0, 2, 0, 2] = Wfit[0, 2, 2, 0] = kt_cross[
          10
      ]
      Wfit[2, 0, 0, 2] = Wfit[2, 0, 2, 0] = Wfit[2, 2, 0, 0] = kt_cross[
          10
      ]
  
      # Wyyzz
      Wfit[1, 1, 2, 2] = Wfit[1, 2, 1, 2] = Wfit[1, 2, 2, 1] = kt_cross[
          11
      ]
      Wfit[2, 1, 1, 2] = Wfit[2, 2, 1, 1] = Wfit[2, 1, 2, 1] = kt_cross[
          11
      ]
  
      # Wxxyz
      Wfit[0, 0, 1, 2] = Wfit[0, 0, 2, 1] = Wfit[0, 1, 0, 2] = kt_cross[
          12
      ]
      Wfit[0, 1, 2, 0] = Wfit[0, 2, 0, 1] = Wfit[0, 2, 1, 0] = kt_cross[
          12
      ]
      Wfit[1, 0, 0, 2] = Wfit[1, 0, 2, 0] = Wfit[1, 2, 0, 0] = kt_cross[
          12
      ]
      Wfit[2, 0, 0, 1] = Wfit[2, 0, 1, 0] = Wfit[2, 1, 0, 0] = kt_cross[
          12
      ]
  
      # Wxyyz
      Wfit[0, 1, 1, 2] = Wfit[0, 1, 2, 1] = Wfit[0, 2, 1, 1] = kt_cross[
          13
      ]
      Wfit[1, 0, 1, 2] = Wfit[1, 1, 0, 2] = Wfit[1, 1, 2, 0] = kt_cross[
          13
      ]
      Wfit[1, 2, 0, 1] = Wfit[1, 2, 1, 0] = Wfit[2, 0, 1, 1] = kt_cross[
          13
      ]
      Wfit[2, 1, 0, 1] = Wfit[2, 1, 1, 0] = Wfit[1, 0, 2, 1] = kt_cross[
          13
      ]
  
      # Wxyzz
      Wfit[0, 1, 2, 2] = Wfit[0, 2, 1, 2] = Wfit[0, 2, 2, 1] = kt_cross[
          14
      ]
      Wfit[1, 0, 2, 2] = Wfit[1, 2, 0, 2] = Wfit[1, 2, 2, 0] = kt_cross[
          14
      ]
      Wfit[2, 0, 1, 2] = Wfit[2, 0, 2, 1] = Wfit[2, 1, 0, 2] = kt_cross[
          14
      ]
      Wfit[2, 1, 2, 0] = Wfit[2, 2, 0, 1] = Wfit[2, 2, 1, 0] = kt_cross[
          14
      ]
  
      # Function to be tested
      W4D = dki.Wcons(kt_cross)
  
      Wfit = Wfit.reshape(-1)
      W4D = W4D.reshape(-1)
  
      assert_array_almost_equal(W4D, Wfit)
  
imports: import numpy
  import random
  import dipy.reconst.dki
  import dipy.reconst.dti
  from numpy.testing import assert_array_almost_equal, assert_array_equal, assert_almost_equal, assert_raises
  from dipy.sims.voxel import multi_tensor_dki
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.core.gradients import gradient_table
  from dipy.data import get_fnames
  from dipy.reconst.dti import from_lower_triangular, decompose_tensor
  from dipy.reconst.dki import mean_kurtosis, carlson_rf, carlson_rd, axial_kurtosis, radial_kurtosis, mean_kurtosis_tensor, _positive_evals, lower_triangular, kurtosis_fractional_anisotropy
  from dipy.core.sphere import Sphere
  from dipy.data import default_sphere
  from dipy.core.geometry import sphere2cart
  from dipy.utils.optpkg import optional_package
  from dipy.utils.tripwire import TripWireError
label_desc: Use image node_id 12 for calling a global function with example usage: test_Wcons() without return types