code: def test_csd_predict(rng):
      """
      Test prediction API
      """
      SNR = 100
      S0 = 1
      _, fbvals, fbvecs = get_fnames("small_64D")
      bvals, bvecs = read_bvals_bvecs(fbvals, fbvecs)
      gtab = gradient_table(bvals, bvecs)
      mevals = np.array(
          ([0.0015, 0.0003, 0.0003], [0.0015, 0.0003, 0.0003])
      )
      angles = [(0, 0), (60, 0)]
      S, _ = multi_tensor(
          gtab, mevals, S0, angles=angles, fractions=[50, 50], snr=SNR
      )
      sphere = small_sphere
      multi_tensor_odf(sphere.vertices, mevals, angles, [50, 50])
      response = (np.array([0.0015, 0.0003, 0.0003]), S0)
  
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          csd = ConstrainedSphericalDeconvModel(gtab, response)
      csd_fit = csd.fit(S)
  
      # Predicting from a fit should give the same result as predicting from a
      # model, S0 is 1 by default
      prediction1 = csd_fit.predict()
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          prediction2 = csd.predict(csd_fit.shm_coeff)
      npt.assert_array_equal(prediction1, prediction2)
      npt.assert_array_equal(prediction1[..., gtab.b0s_mask], 1.0)
  
      # Same with a different S0
      prediction1 = csd_fit.predict(S0=123.0)
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          prediction2 = csd.predict(csd_fit.shm_coeff, S0=123.0)
      npt.assert_array_equal(prediction1, prediction2)
      npt.assert_array_equal(prediction1[..., gtab.b0s_mask], 123.0)
  
      # For "well behaved" coefficients, the model should be able to find the
      # coefficients from the predicted signal.
      coeff = rng.random(csd_fit.shm_coeff.shape) - 0.5
      coeff[..., 0] = 10.0
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          S = csd.predict(coeff)
      csd_fit = csd.fit(S)
      npt.assert_array_almost_equal(coeff, csd_fit.shm_coeff)
  
      # Test predict on nd-data set
      S_nd = np.zeros((2, 3, 4, S.size))
      S_nd[:] = S
      fit = csd.fit(S_nd)
      predict1 = fit.predict()
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore",
              message=descoteaux07_legacy_msg,
              category=PendingDeprecationWarning,
          )
          predict2 = csd.predict(fit.shm_coeff)
      npt.assert_array_almost_equal(predict1, predict2)
  
imports: import warnings
  import numpy
  import numpy.testing
  from numpy.testing import assert_, assert_equal, assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from dipy.testing import assert_greater, assert_greater_equal
  from dipy.data import get_sphere, get_fnames, default_sphere, small_sphere
  from dipy.sims.voxel import multi_tensor, single_tensor, multi_tensor_odf, all_tensor_evecs, single_tensor_odf
  from dipy.core.gradients import gradient_table
  from dipy.core.sphere import Sphere, HemiSphere
  from dipy.core.sphere_stats import angular_similarity
  from dipy.reconst.csdeconv import ConstrainedSphericalDeconvModel, ConstrainedSDTModel, forward_sdeconv_mat, odf_deconv, odf_sh_to_sharp, mask_for_response_ssst, response_from_mask_ssst, response_from_mask, auto_response_ssst, auto_response, recursive_response
  from dipy.direction.peaks import peak_directions
  from dipy.reconst.dti import TensorModel, fractional_anisotropy
  from dipy.reconst.shm import descoteaux07_legacy_msg, QballModel, sf_to_sh, sh_to_sf, real_sh_descoteaux, sph_harm_ind_list
  from dipy.reconst.shm import lazy_index
  from dipy.utils.deprecator import ExpiredDeprecationError
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 14 for calling a global function with example usage: test_csd_predict(rng) without return types