code: def test_infer_dim_by_explained_variance():
      X = da.from_array(iris.data, chunks=iris.data.shape)
      pca = dd.PCA(n_components=0.95, svd_solver="full")
      pca.fit(X)
      assert pca.n_components == 0.95
      assert pca.n_components_ == 2
  
      pca = dd.PCA(n_components=0.01, svd_solver="full")
      pca.fit(X)
      assert pca.n_components == 0.01
      assert pca.n_components_ == 1
  
      # Can't do this
      rng = np.random.RandomState(0)
      # more features than samples
      X = rng.rand(5, 20)
      pca = dd.PCA(n_components=0.5, svd_solver="full").fit(X)
      assert pca.n_components == 0.5
      assert pca.n_components_ == 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 20 for calling a global function with example usage: test_infer_dim_by_explained_variance() without return types