code: def test_singular_values():
      # Check that the PCA output has the correct singular values
  
      rng = np.random.RandomState(0)
      n_samples = 100
      n_features = 80
  
      X = rng.randn(n_samples, n_features)
      dX = da.from_array(X, chunks=(50, n_features))
  
      pca = sd.PCA(
          n_components=2, svd_solver="full", random_state=rng
      ).fit(X)
      apca = dd.PCA(
          n_components=2, svd_solver="full", random_state=rng
      ).fit(dX)
      rpca = dd.PCA(
          n_components=2,
          svd_solver="randomized",
          random_state=rng,
          iterated_power=4,
      ).fit(dX)
      assert_array_almost_equal(
          pca.singular_values_, apca.singular_values_, 12
      )
      assert_array_almost_equal(
          pca.singular_values_, rpca.singular_values_, 1
      )
      assert_array_almost_equal(
          apca.singular_values_, rpca.singular_values_, 1
      )
  
      # Compare to the Frobenius norm
      X_pca = pca.transform(X)
      X_apca = apca.transform(dX)
      X_rpca = rpca.transform(dX)
      assert_array_almost_equal(
          np.sum(pca.singular_values_**2.0),
          np.linalg.norm(X_pca, "fro") ** 2.0,
          12,
      )
      assert_array_almost_equal(
          np.sum(apca.singular_values_**2.0),
          np.linalg.norm(X_apca, "fro") ** 2.0,
          9,
      )
      assert_array_almost_equal(
          np.sum(rpca.singular_values_**2.0),
          np.linalg.norm(X_rpca, "fro") ** 2.0,
          0,
      )
  
      # Compare to the 2-norms of the score vectors
      assert_array_almost_equal(
          pca.singular_values_,
          np.sqrt(np.sum(X_pca**2.0, axis=0)),
          12,
      )
      assert_array_almost_equal(
          apca.singular_values_,
          np.sqrt(np.sum(X_apca**2.0, axis=0)),
          12,
      )
      assert_array_almost_equal(
          rpca.singular_values_,
          np.sqrt(np.sum(X_rpca**2.0, axis=0)),
          2,
      )
  
imports: from itertools import product
  import dask.array
  import dask.dataframe
  import numpy
  import pandas
  import pytest
  import scipy
  import sklearn.decomposition
  from dask.array.utils import assert_eq
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_raises
  from sklearn import datasets
  from sklearn.utils import check_random_state
  import dask_ml.decomposition
  from dask_ml._compat import DASK_2_26_0
  from dask_ml.utils import assert_estimator_equal, flip_vector_signs, svd_flip
label_desc: Use image node_id 7 for calling a global function with example usage: test_singular_values() without return types