code: def test_precomputed_kernel_not_psd(solver):
      """Check how KernelPCA works with non-PSD kernels depending on n_components
  
      Tests for all methods what happens with a non PSD gram matrix (this
      can happen in an isomap scenario, or with custom kernel functions, or
      maybe with ill-posed datasets).
  
      When ``n_component`` is large enough to capture a negative eigenvalue, an
      error should be raised. Otherwise, KernelPCA should run without error
      since the negative eigenvalues are not selected.
      """
  
      # a non PSD kernel with large eigenvalues, already centered
      # it was captured from an isomap call and multiplied by 100 for compacity
      K = [
          [4.48, -1.0, 8.07, 2.33, 2.33, 2.33, -5.76, -12.78],
          [-1.0, -6.48, 4.5, -1.24, -1.24, -1.24, -0.81, 7.49],
          [8.07, 4.5, 15.48, 2.09, 2.09, 2.09, -11.1, -23.23],
          [2.33, -1.24, 2.09, 4.0, -3.65, -3.65, 1.02, -0.9],
          [2.33, -1.24, 2.09, -3.65, 4.0, -3.65, 1.02, -0.9],
          [2.33, -1.24, 2.09, -3.65, -3.65, 4.0, 1.02, -0.9],
          [-5.76, -0.81, -11.1, 1.02, 1.02, 1.02, 4.86, 9.75],
          [-12.78, 7.49, -23.23, -0.9, -0.9, -0.9, 9.75, 21.46],
      ]
      # this gram matrix has 5 positive eigenvalues and 3 negative ones
      # [ 52.72,   7.65,   7.65,   5.02,   0.  ,  -0.  ,  -6.13, -15.11]
  
      # 1. ask for enough components to get a significant negative one
      kpca = KernelPCA(
          kernel="precomputed", eigen_solver=solver, n_components=7
      )
      # make sure that the appropriate error is raised
      with pytest.raises(
          ValueError, match="There are significant negative eigenvalues"
      ):
          kpca.fit(K)
  
      # 2. ask for a small enough n_components to get only positive ones
      kpca = KernelPCA(
          kernel="precomputed", eigen_solver=solver, n_components=2
      )
      if solver == "randomized":
          # the randomized method is still inconsistent with the others on this
          # since it selects the eigenvalues based on the largest 2 modules, not
          # on the largest 2 values.
          #
          # At least we can ensure that we return an error instead of returning
          # the wrong eigenvalues
          with pytest.raises(
              ValueError,
              match="There are significant negative eigenvalues",
          ):
              kpca.fit(K)
      else:
          # general case: make sure that it works
          kpca.fit(K)
  
imports: import warnings
  import numpy
  import pytest
  import sklearn
  from sklearn.datasets import load_iris, make_blobs, make_circles
  from sklearn.decomposition import PCA, KernelPCA
  from sklearn.exceptions import NotFittedError
  from sklearn.linear_model import Perceptron
  from sklearn.metrics.pairwise import rbf_kernel
  from sklearn.model_selection import GridSearchCV
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import StandardScaler
  from sklearn.utils._testing import assert_allclose, assert_array_almost_equal, assert_array_equal
  from sklearn.utils.fixes import CSR_CONTAINERS
  from sklearn.utils.validation import _check_psd_eigenvalues
label_desc: Use image node_id 16 for calling a global function with example usage: test_precomputed_kernel_not_psd(solver) without return types