code: def test_gradient_table_from_bvals_bvecs():
      sq2 = np.sqrt(2) / 2
      bvals = [0, 1, 2, 3, 4, 5, 6, 0]
      bvecs = np.array(
          [
              [0, 0, 0],
              [1, 0, 0],
              [0, 1, 0],
              [0, 0, 1],
              [sq2, sq2, 0],
              [sq2, 0, sq2],
              [0, sq2, sq2],
              [0, 0, 0],
          ]
      )
  
      gt = gradient_table_from_bvals_bvecs(bvals, bvecs, b0_threshold=0)
      npt.assert_array_equal(gt.bvecs, bvecs)
      npt.assert_array_equal(gt.bvals, bvals)
      npt.assert_array_equal(
          gt.gradients, np.reshape(bvals, (-1, 1)) * bvecs
      )
      npt.assert_array_equal(gt.b0s_mask, [1, 0, 0, 0, 0, 0, 0, 1])
  
      # Test nans are replaced by 0
      new_bvecs = bvecs.copy()
      new_bvecs[[0, -1]] = np.nan
      gt = gradient_table_from_bvals_bvecs(
          bvals, new_bvecs, b0_threshold=0
      )
      npt.assert_array_equal(gt.bvecs, bvecs)
  
      # b-value > 0 for non-unit vector
      bad_bvals = [2, 1, 2, 3, 4, 5, 6, 0]
      npt.assert_raises(
          ValueError,
          gradient_table_from_bvals_bvecs,
          bad_bvals,
          bvecs,
          b0_threshold=0.0,
      )
      # num_gard inconsistent bvals, bvecs
      bad_bvals = np.ones(7)
      npt.assert_raises(
          ValueError,
          gradient_table_from_bvals_bvecs,
          bad_bvals,
          bvecs,
          b0_threshold=0.0,
      )
      # negative bvals
      bad_bvals = [-1, -1, -1, -5, -6, -10]
      npt.assert_raises(
          ValueError,
          gradient_table_from_bvals_bvecs,
          bad_bvals,
          bvecs,
          b0_threshold=0.0,
      )
      # bvals not 1d
      bad_bvals = np.ones((1, 8))
      npt.assert_raises(
          ValueError,
          gradient_table_from_bvals_bvecs,
          bad_bvals,
          bvecs,
          b0_threshold=0.0,
      )
      # bvec not 2d
      bad_bvecs = np.ones((1, 8, 3))
      npt.assert_raises(
          ValueError,
          gradient_table_from_bvals_bvecs,
          bvals,
          bad_bvecs,
          b0_threshold=0.0,
      )
      # bvec not (N, 3)
      bad_bvecs = np.ones((8, 2))
      npt.assert_raises(
          ValueError,
          gradient_table_from_bvals_bvecs,
          bvals,
          bad_bvecs,
          b0_threshold=0.0,
      )
      # bvecs not unit vectors
      bad_bvecs = bvecs * 2
      npt.assert_raises(
          ValueError,
          gradient_table_from_bvals_bvecs,
          bvals,
          bad_bvecs,
          b0_threshold=0.0,
      )
  
      # Test **kargs get passed along
      gt = gradient_table_from_bvals_bvecs(
          bvals, bvecs, b0_threshold=0, big_delta=5, small_delta=2
      )
      npt.assert_equal(gt.big_delta, 5)
      npt.assert_equal(gt.small_delta, 2)
  
imports: import warnings
  import numpy
  import numpy.testing
  import pytest
  from dipy.data import get_fnames
  from dipy.core.gradients import b0_threshold_empty_gradient_message, b0_threshold_update_slicing_message, gradient_table, GradientTable, gradient_table_from_bvals_bvecs, gradient_table_from_qvals_bvecs, gradient_table_from_gradient_strength_bvecs, WATER_GYROMAGNETIC_RATIO, mask_non_weighted_bvals, orientation_to_string, reorient_bvecs, generate_bvecs, check_multi_b, round_bvals, get_bval_indices, unique_bvals_magnitude, unique_bvals_tolerance, unique_bvals, params_to_btens, btens_to_params, orientation_from_string, reorient_vectors
  from dipy.core.geometry import vec2vec_rotmat, vector_norm
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.utils.deprecator import ExpiredDeprecationError
  from dipy.testing import clear_and_catch_warnings
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 8 for calling a global function with example usage: test_gradient_table_from_bvals_bvecs() without return types