code: def voxel_sizes(affine):
      r"""Return voxel size for each input axis given `affine`
  
      The `affine` is the mapping between array (voxel) coordinates and mm
      (world) coordinates.
  
      The voxel size for the first voxel (array) axis is the distance moved in
      world coordinates when moving one unit along the first voxel (array) axis.
      This is the distance between the world coordinate of voxel (0, 0, 0) and
      the world coordinate of voxel (1, 0, 0).  The world coordinate vector of
      voxel coordinate vector (0, 0, 0) is given by ``v0 = affine.dot((0, 0, 0,
      1)[:3]``.  The world coordinate vector of voxel vector (1, 0, 0) is
      ``v1_ax1 = affine.dot((1, 0, 0, 1))[:3]``.  The final 1 in the voxel
      vectors and the ``[:3]`` at the end are because the affine works on
      homogeneous coordinates.  The translations part of the affine is ``trans =
      affine[:3, 3]``, and the rotations, zooms and shearing part of the affine
      is ``rzs = affine[:3, :3]``. Because of the final 1 in the input voxel
      vector, ``v0 == rzs.dot((0, 0, 0)) + trans``, and ``v1_ax1 == rzs.dot((1,
      0, 0)) + trans``, and the difference vector is ``rzs.dot((0, 0, 0)) -
      rzs.dot((1, 0, 0)) == rzs.dot((1, 0, 0)) == rzs[:, 0]``.  The distance
      vectors in world coordinates between (0, 0, 0) and (1, 0, 0), (0, 1, 0),
      (0, 0, 1) are given by ``rzs.dot(np.eye(3)) = rzs``.  The voxel sizes are
      the Euclidean lengths of the distance vectors.  So, the voxel sizes are
      the Euclidean lengths of the columns of the affine (excluding the last row
      and column of the affine).
  
      Parameters
      ----------
      affine : 2D array-like
          Affine transformation array.  Usually shape (4, 4), but can be any 2D
          array.
  
      Returns
      -------
      vox_sizes : 1D array
          Voxel sizes for each input axis of affine.  Usually 1D array length 3,
          but in general has length (N-1) where input `affine` is shape (M, N).
      """
      top_left = affine[:-1, :-1]
      return np.sqrt(np.sum(top_left**2, axis=0))
  
file_path: nibabel/nibabel/affines.py
imports: from functools import reduce
  import numpy
label_desc: Use image node_id 6 for calling a global function with example usage: voxel_sizes(affine) and returns: np