code: def test_spca_n_components_(SPCA, n_components):
      rng = np.random.RandomState(0)
      n_samples, n_features = 12, 10
      X = rng.randn(n_samples, n_features)
  
      model = SPCA(n_components=n_components).fit(X)
  
      if n_components is not None:
          assert model.n_components_ == n_components
      else:
          assert model.n_components_ == n_features
  
imports: import sys
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from sklearn.decomposition import PCA, MiniBatchSparsePCA, SparsePCA
  from sklearn.utils import check_random_state
  from sklearn.utils._testing import assert_allclose, assert_array_almost_equal, if_safe_multiprocessing_with_blas
label_desc: Use image node_id 12 for calling a global function with example usage: test_spca_n_components_(SPCA, n_components) without return types