code: def setup_module():
      global gtab, ivim_fit_single, ivim_model_trr, data_single, params_trr, data_multi, ivim_params_trr, D_star, D, f, S0, gtab_with_multiple_b0, noisy_single, mevals, gtab_no_b0, ivim_fit_multi, ivim_model_VP, f_VP, D_star_VP, D_VP, params_VP
  
      # Let us generate some data for testing.
      bvals = np.array(
          [
              0.0,
              10.0,
              20.0,
              30.0,
              40.0,
              60.0,
              80.0,
              100.0,
              120.0,
              140.0,
              160.0,
              180.0,
              200.0,
              300.0,
              400.0,
              500.0,
              600.0,
              700.0,
              800.0,
              900.0,
              1000.0,
          ]
      )
      N = len(bvals)
      bvecs = generate_bvecs(N)
      gtab = gradient_table(bvals, bvecs.T, b0_threshold=0)
  
      S0, f, D_star, D = 1000.0, 0.132, 0.00885, 0.000921
      # params for a single voxel
      params_trr = np.array([S0, f, D_star, D])
  
      mevals = np.array(([D_star, D_star, D_star], [D, D, D]))
      # This gives an isotropic signal.
      signal = multi_tensor(
          gtab,
          mevals,
          snr=None,
          S0=S0,
          fractions=[f * 100, 100 * (1 - f)],
      )
      # Single voxel data
      data_single = signal[0]
  
      data_multi = np.zeros((2, 2, 1, len(gtab.bvals)))
      data_multi[0, 0, 0] = data_multi[0, 1, 0] = data_multi[
          1, 0, 0
      ] = data_multi[1, 1, 0] = data_single
  
      ivim_params_trr = np.zeros((2, 2, 1, 4))
      ivim_params_trr[0, 0, 0] = ivim_params_trr[0, 1, 0] = params_trr
      ivim_params_trr[1, 0, 0] = ivim_params_trr[1, 1, 0] = params_trr
  
      msg = "Bounds for this fit have been set from experiments .*"
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore", message=msg, category=UserWarning
          )
          ivim_model_trr = IvimModel(gtab, fit_method="trr")
          ivim_model_one_stage = IvimModel(gtab, fit_method="trr")
  
      ivim_fit_single = ivim_model_trr.fit(data_single)
      ivim_fit_multi = ivim_model_trr.fit(data_multi)
  
      ivim_model_one_stage.fit(data_single)
      ivim_model_one_stage.fit(data_multi)
  
      bvals_no_b0 = np.array(
          [
              5.0,
              10.0,
              20.0,
              30.0,
              40.0,
              60.0,
              80.0,
              100.0,
              120.0,
              140.0,
              160.0,
              180.0,
              200.0,
              300.0,
              400.0,
              500.0,
              600.0,
              700.0,
              800.0,
              900.0,
              1000.0,
          ]
      )
  
      gtab_no_b0 = gradient_table(bvals_no_b0, bvecs.T, b0_threshold=0)
  
      bvals_with_multiple_b0 = np.array(
          [
              0.0,
              0.0,
              0.0,
              0.0,
              40.0,
              60.0,
              80.0,
              100.0,
              120.0,
              140.0,
              160.0,
              180.0,
              200.0,
              300.0,
              400.0,
              500.0,
              600.0,
              700.0,
              800.0,
              900.0,
              1000.0,
          ]
      )
  
      bvecs_with_multiple_b0 = generate_bvecs(N)
      gtab_with_multiple_b0 = gradient_table(
          bvals_with_multiple_b0,
          bvecs_with_multiple_b0.T,
          b0_threshold=0,
      )
  
      noisy_single = np.array(
          [
              4243.71728516,
              4317.81298828,
              4244.35693359,
              4439.36816406,
              4420.06201172,
              4152.30078125,
              4114.34912109,
              4104.59375,
              4151.61914062,
              4003.58374023,
              4013.68408203,
              3906.39428711,
              3909.06079102,
              3495.27197266,
              3402.57006836,
              3163.10180664,
              2896.04003906,
              2663.7253418,
              2614.87695312,
              2316.55371094,
              2267.7722168,
          ]
      )
  
      noisy_multi = np.zeros((2, 2, 1, len(gtab.bvals)))
      noisy_multi[0, 1, 0] = noisy_multi[1, 0, 0] = noisy_multi[
          1, 1, 0
      ] = noisy_single
      noisy_multi[0, 0, 0] = data_single
  
      msg = "Bounds for this fit have been set from experiments .*"
      with warnings.catch_warnings():
          warnings.filterwarnings(
              "ignore", message=msg, category=UserWarning
          )
          ivim_model_VP = IvimModel(gtab, fit_method="VarPro")
      f_VP, D_star_VP, D_VP = 0.13, 0.0088, 0.000921
      # params for a single voxel
      params_VP = np.array([f, D_star, D])
  
      ivim_params_VP = np.zeros((2, 2, 1, 3))
      ivim_params_VP[0, 0, 0] = ivim_params_VP[0, 1, 0] = params_VP
      ivim_params_VP[1, 0, 0] = ivim_params_VP[1, 1, 0] = params_VP
  
imports: import warnings
  import numpy
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_raises, assert_array_less, assert_, assert_equal
  from dipy.testing import assert_greater_equal
  import pytest
  from dipy.reconst.ivim import ivim_prediction, IvimModel
  from dipy.core.gradients import gradient_table, generate_bvecs
  from dipy.sims.voxel import multi_tensor
  from dipy.utils.optpkg import optional_package
label_desc: Use image node_id 1 for calling a global function with example usage: setup_module() without return types