code: def test_downsample():
      """Test resampling of the VolumeImg with a 1/2 down-sampling affine."""
      shape = (6, 3, 6, 2)
      data = np.random.random(shape)
      affine = np.eye(4)
      ref_im = VolumeImg(data, affine, "mine")
      rot_im = ref_im.as_volume_img(2 * affine, interpolation="nearest")
      downsampled = data[::2, ::2, ::2, ...]
      x, y, z = downsampled.shape[:3]
      np.testing.assert_almost_equal(
          downsampled, rot_im.get_fdata()[:x, :y, :z, ...]
      )
  
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 5 for calling a global function with example usage: test_downsample() without return types