code: def test_snr(rng=None):
      s = single_tensor(gtab)
  
      # For reasonably large SNR, var(signal) ~= sigma**2, where sigma = 1/SNR
      for snr in [5, 10, 20]:
          sigma = 1.0 / snr
          for j in range(1000):
              s_noise = add_noise(
                  s, snr, 1, noise_type="rician", rng=rng
              )
  
          assert_array_almost_equal(
              np.var(s_noise - s), sigma**2, decimal=2
          )
  
file_path: dipy/dipy/sims/tests/test_voxel.py
imports: import numpy
  from numpy.testing import assert_array_equal, assert_array_almost_equal, assert_, assert_almost_equal
  from dipy.sims.voxel import _check_directions, all_tensor_evecs, add_noise, single_tensor, sticks_and_ball, multi_tensor_dki, kurtosis_element, dki_signal, multi_tensor
  from dipy.data import get_fnames
  from dipy.core.gradients import gradient_table
  from dipy.io.gradients import read_bvals_bvecs
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 6 for calling a global function with example usage: test_snr(rng) without return types