code: def validated_apply_affine(T, xyz):
      # This was the original apply_affine implementation that we've stashed here
      # to test against
      xyz = np.asarray(xyz)
      shape = xyz.shape[0:-1]
      XYZ = np.dot(np.reshape(xyz, (np.prod(shape), 3)), T[0:3, 0:3].T)
      XYZ[:, 0] += T[0, 3]
      XYZ[:, 1] += T[1, 3]
      XYZ[:, 2] += T[2, 3]
      XYZ = np.reshape(XYZ, shape + (3,))
      return XYZ
  
file_path: nibabel/nibabel/tests/test_affines.py
imports: from itertools import product
  import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from ..affines import AffineError, append_diag, apply_affine, dot_reduce, from_matvec, obliquity, rescale_affine, to_matvec, voxel_sizes
  from ..eulerangles import euler2mat
  from ..orientations import aff2axcodes
label_desc: Use image node_id 1 for calling a global function with example usage: validated_apply_affine(T, xyz) and returns: XYZ