code: def test_resampled_to_img():
      """Trivial test of resampled_to_img."""
      shape = (5, 4, 3, 2)
      data = np.random.random(shape)
      affine = np.random.random((4, 4))
      ref_im = VolumeImg(data, affine, "mine")
      assert_almost_equal(
          data, ref_im.as_volume_img(affine=ref_im.affine).get_fdata()
      )
      assert_almost_equal(
          data, ref_im.resampled_to_img(ref_im).get_fdata()
      )
  
      # Check that we cannot resample to another image in a different
      # world.
      other_im = VolumeImg(data, affine, "other")
      pytest.raises(CompositionError, other_im.resampled_to_img, ref_im)
  
      # Also check that trying to resample on a non 3D grid will raise an
      # error
      pytest.raises(ValueError, ref_im.as_volume_img, None, (2, 2))
  
imports: import copy
  import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_equal
  from ...transforms.affine_transform import AffineTransform
  from ...transforms.affine_utils import from_matrix_vector
  from ...transforms.transform import Transform
  from ..volume_img import CompositionError, VolumeImg
label_desc: Use image node_id 10 for calling a global function with example usage: test_resampled_to_img() without return types