code: def same_transform(taff, ornt, shape):
      # Applying transformations implied by `ornt` to a made-up array
      # ``arr`` of shape `shape`, results in ``t_arr``. When the point
      # indices from ``arr`` are transformed by (the inverse of) `taff`,
      # and we index into ``t_arr`` with these transformed points, then we
      # should get the same values as we would from indexing into arr with
      # the untransformed points.
      shape = np.array(shape)
      size = np.prod(shape)
      arr = np.arange(size).reshape(shape)
      # apply ornt transformations
      t_arr = apply_orientation(arr, ornt)
      # get all point indices in arr
      i, j, k = shape
      arr_pts = np.mgrid[:i, :j, :k].reshape((3, -1))
      # inverse of taff takes us from point index in arr to point index in
      # t_arr
      itaff = np.linalg.inv(taff)
      # apply itaff so that points indexed in t_arr should correspond
      o2t_pts = np.dot(itaff[:3, :3], arr_pts) + itaff[:3, 3][:, None]
      assert np.allclose(np.round(o2t_pts), o2t_pts)
      # fancy index out the t_arr values
      vals = t_arr[tuple(o2t_pts.astype("i"))]
      return np.all(vals == arr.ravel())
  
file_path: nibabel/nibabel/tests/test_orientations.py
imports: import warnings
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from ..affines import from_matvec, to_matvec
  from ..orientations import OrientationError, aff2axcodes, apply_orientation, axcodes2ornt, flip_axis, inv_ornt_aff, io_orientation, ornt2axcodes, ornt_transform
  from ..testing import expires
label_desc: Use image node_id 1 for calling a global function with example usage: same_transform(taff, ornt, shape) and returns: np