code: def test_pca(n_components, whiten):
      """Test PCA equivalence."""
      pytest.importorskip("sklearn")
      from sklearn.decomposition import PCA
  
      n_samples, n_dim = 1000, 10
      X = np.random.RandomState(0).randn(n_samples, n_dim)
      X[:, -1] = np.mean(X[:, :-1], axis=-1)  # true X dim is ndim - 1
      X_orig = X.copy()
      pca_skl = PCA(n_components, whiten=whiten, svd_solver="full")
      pca_mne = _PCA(n_components, whiten=whiten)
      X_skl = pca_skl.fit_transform(X)
      assert_array_equal(X, X_orig)
      X_mne = pca_mne.fit_transform(X)
      assert_array_equal(X, X_orig)
      assert_allclose(X_skl, X_mne)
      assert pca_mne.n_components_ == pca_skl.n_components_
      for key in (
          "mean_",
          "components_",
          "explained_variance_",
          "explained_variance_ratio_",
      ):
          val_skl, val_mne = getattr(pca_skl, key), getattr(
              pca_mne, key
          )
          assert_allclose(val_skl, val_mne)
      if isinstance(n_components, float):
          assert pca_mne.n_components_ == n_dim - 1
      elif isinstance(n_components, int):
          assert pca_mne.n_components_ == n_components
      elif n_components == "mle":
          assert pca_mne.n_components_ == n_dim - 1
      else:
          assert n_components is None
          assert pca_mne.n_components_ == n_dim
  
imports: from copy import deepcopy
  from datetime import datetime, timezone
  from io import StringIO
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy import sparse
  from mne import pick_types, read_cov, read_evokeds
  from mne._fiff.pick import _picks_by_type
  from mne.epochs import make_fixed_length_epochs
  from mne.io import read_raw_fif
  from mne.time_frequency import tfr_morlet
  from mne.utils import _PCA, _apply_scaling_array, _apply_scaling_cov, _array_equal_nan, _cal_to_julian, _custom_lru_cache, _dt_to_julian, _freq_mask, _get_inst_data, _julian_to_cal, _julian_to_dt, _reg_pinv, _ReuseCycle, _time_mask, _undo_scaling_array, _undo_scaling_cov, compute_corr, create_slices, grand_average, hashfunc, numerics, object_diff, object_hash, object_size, random_permutation, sum_squared
  from mne.utils.numerics import _LRU_CACHE_MAXSIZES, _LRU_CACHES
label_desc: Use image node_id 14 for calling a global function with example usage: test_pca(n_components, whiten) without return types