code: def test_iter_axis():
      # axis iteration helper function.  This function also tests rollimg,
      # because iter_axis uses rollimg
      iter_axis = image.iter_axis
      data = np.arange(24).reshape((4, 3, 2))
      img = Image(data, AffineTransform("ijk", "xyz", np.eye(4)))
      for ax_id, ax_no in (
          ("i", 0),
          ("j", 1),
          ("k", 2),
          ("x", 0),
          ("y", 1),
          ("z", 2),
          (0, 0),
          (1, 1),
          (2, 2),
          (-1, 2),
      ):
          slices = list(iter_axis(img, ax_id))
          expected_shape = list(data.shape)
          g_len = expected_shape.pop(ax_no)
          assert len(slices) == g_len
          for s in slices:
              assert list(s.shape) == expected_shape
          # test asarray
          slicer = [slice(None) for i in range(data.ndim)]
          for i, s in enumerate(iter_axis(img, ax_id, asarray=True)):
              slicer[ax_no] = i
              assert_array_equal(s, data[tuple(slicer)])
  
imports: import warnings
  from itertools import chain
  import nibabel
  import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from ...api import data_generator, parcels, write_data
  from ...reference.coordinate_map import AffineTransform, AxisError
  from ...reference.coordinate_system import CoordinateSystem
  from ..None import image
  from ..image import Image, is_image, iter_axis, rollimg
label_desc: Use image node_id 19 for calling a global function with example usage: test_iter_axis() without return types