code: def test_read_img_arr_or_path(rng):
      data = rng.random((4, 4, 4, 3))
      aff = np.eye(4)
      aff[:3, :] = rng.standard_normal((3, 4))
      img = nib.Nifti1Image(data, aff)
      path = tempfile.NamedTemporaryFile().name + ".nii.gz"
      nib.save(img, path)
      for this in [data, img, path]:
          dd, aa = read_img_arr_or_path(this, affine=aff)
          assert np.allclose(dd, data)
          assert np.allclose(aa, aff)
  
      # Tests that if an array is provided, but no affine, an error is raised:
      with pytest.raises(ValueError):
          read_img_arr_or_path(data)
  
      # Tests that the affine is recovered correctly from path:
      dd, aa = read_img_arr_or_path(path)
      assert np.allclose(dd, data)
      assert np.allclose(aa, aff)
  
imports: import tempfile
  from urllib.error import URLError, HTTPError
  import pytest
  import nibabel
  import numpy
  from numpy.testing import assert_allclose, assert_array_equal, assert_
  import trx.trx_file_memmap
  from dipy.data import get_fnames
  from dipy.io.streamline import load_tractogram
  from dipy.io.utils import create_nifti_header, decfa, decfa_to_float, get_reference_info, is_reference_info_valid, read_img_arr_or_path
  from dipy.testing.decorators import set_random_number_generator
label_desc: Use image node_id 15 for calling a global function with example usage: test_read_img_arr_or_path(rng) without return types