code: def test_pca_inverse(setup):
      # Test that the projection of data can be inverted
      rng = np.random.RandomState(0)
      n, p = 50, 3
      X = mt.tensor(rng.randn(n, p))  # spherical data
      X[:, 1] *= 0.00001  # make middle component relatively small
      X += [5, 4, 3]  # make a large mean
  
      # same check that we can find the original data from the transformed
      # signal (since the data is almost of rank n_components)
      pca = PCA(n_components=2, svd_solver="full").fit(X)
      Y = pca.transform(X)
      Y_inverse = pca.inverse_transform(Y)
      assert_almost_equal(X.to_numpy(), Y_inverse.to_numpy(), decimal=3)
  
      # same as above with whitening (approximate reconstruction)
      for solver in solver_list:
          pca = PCA(n_components=2, whiten=True, svd_solver=solver)
          pca.fit(X)
          Y = pca.transform(X)
          Y_inverse = pca.inverse_transform(Y)
          assert_almost_equal(
              X.to_numpy(), Y_inverse.to_numpy(), decimal=3
          )
  
imports: from itertools import product
  import numpy
  import pytest
  import scipy
  from sklearn import datasets
  from sklearn.utils._testing import assert_array_almost_equal, assert_almost_equal, assert_raises_regex, assert_raise_message, assert_raises
  from ....None import tensor
  from .._pca import PCA, _assess_dimension, _infer_dimension
label_desc: Use image node_id 7 for calling a global function with example usage: test_pca_inverse(setup) without return types