code: def test_inertia_tensor_3d():
      image = draw.ellipsoid(10, 5, 3)
      T0 = inertia_tensor(image)
      eig0, V0 = np.linalg.eig(T0)
      # principal axis of ellipse = eigenvector of smallest eigenvalue
      v0 = V0[:, np.argmin(eig0)]
  
      assert np.allclose(v0, [1, 0, 0]) or np.allclose(-v0, [1, 0, 0])
  
      imrot = ndi.rotate(image.astype(float), 30, axes=(0, 1), order=1)
      Tr = inertia_tensor(imrot)
      eigr, Vr = np.linalg.eig(Tr)
      vr = Vr[:, np.argmin(eigr)]
  
      # Check that axis has rotated by expected amount
      pi, cos, sin = np.pi, np.cos, np.sin
      R = np.array(
          [
              [cos(pi / 6), -sin(pi / 6), 0],
              [sin(pi / 6), cos(pi / 6), 0],
              [0, 0, 1],
          ]
      )
      expected_vr = R @ v0
      assert np.allclose(
          vr, expected_vr, atol=1e-3, rtol=0.01
      ) or np.allclose(-vr, expected_vr, atol=1e-3, rtol=0.01)
  
imports: import itertools
  import numpy
  import pytest
  from scipy import ndimage
  from skimage import draw
  from skimage._shared import testing
  from skimage._shared.testing import assert_allclose, assert_almost_equal, assert_equal
  from skimage._shared.utils import _supported_float_type
  from skimage.measure import centroid, inertia_tensor, inertia_tensor_eigvals, moments, moments_central, moments_coords, moments_coords_central, moments_hu, moments_normalized
label_desc: Use image node_id 16 for calling a global function with example usage: test_inertia_tensor_3d() without return types