code: def test_generate_kernel():
      # Test form and content of kernel generation result.
  
      # load repulsion 724 sphere
      sphere = default_sphere
  
      btable = np.loadtxt(get_fnames("dsi515btable"))
      bvals = btable[:, 0]
      bvecs = btable[:, 1:]
      gtab = gradient_table(bvals, bvecs)
  
      # Kernel parameters
      wm_response = np.array([1.7e-3, 0.2e-3, 0.2e-3])
      gm_response = 0.2e-4
      csf_response = 3.0e-3
  
      # Test kernel shape
      kernel = generate_kernel(
          gtab, sphere, wm_response, gm_response, csf_response
      )
      assert_equal(
          kernel.shape, (len(gtab.bvals), len(sphere.vertices) + 2)
      )
  
      # Verify first column of kernel
      _, theta, phi = cart2sphere(sphere.x, sphere.y, sphere.z)
      S0 = 1  # S0 assumed to be 1
      fi = 100  # volume fraction assumed to be 100%
  
      S, _ = multi_tensor(
          gtab,
          np.array([wm_response]),
          S0,
          [[theta[0] * 180 / np.pi, phi[0] * 180 / np.pi]],
          [fi],
          None,
      )
      assert_almost_equal(kernel[:, 0], S)
  
      # Multi-shell version
      ms_eigenval_count = len(unique_bvals_tolerance(gtab.bvals)) - 1
      wm_response_multi = np.tile(wm_response, (ms_eigenval_count, 1))
      kernel_multi = generate_kernel(
          gtab, sphere, wm_response_multi, gm_response, csf_response
      )
      assert_equal(
          kernel.shape, (len(gtab.bvals), len(sphere.vertices) + 2)
      )
      assert_almost_equal(kernel, kernel_multi)
  
      # Test optional isotropic compartment; should cause last column of zeroes
      kernel = generate_kernel(
          gtab, sphere, wm_response, gm_response=None, csf_response=None
      )
      assert_array_equal(kernel[:, -2], np.zeros(len(gtab.bvals)))
      assert_array_equal(kernel[:, -1], np.zeros(len(gtab.bvals)))
  
imports: import warnings
  import numpy
  from numpy.testing import assert_equal, assert_almost_equal, assert_array_equal, assert_allclose, assert_raises
  from numpy.testing import assert_
  from dipy.reconst.rumba import RumbaSDModel, generate_kernel
  from dipy.reconst.csdeconv import AxSymShResponse
  from dipy.data import get_fnames, dsi_voxels, default_sphere, get_sphere
  from dipy.core.gradients import gradient_table, unique_bvals_tolerance
  from dipy.core.geometry import cart2sphere
  from dipy.core.sphere_stats import angular_similarity
  from dipy.reconst.tests.test_dsi import sticks_and_ball_dummies
  from dipy.sims.voxel import sticks_and_ball, multi_tensor, single_tensor
  from dipy.direction.peaks import peak_directions
  from dipy.reconst.shm import descoteaux07_legacy_msg
label_desc: Use image node_id 8 for calling a global function with example usage: test_generate_kernel() without return types