code: def test_precomputed_nearest_neighbors_filtering():
      # Test precomputed graph filtering when containing too many neighbors
      X, y = make_blobs(
          n_samples=200,
          random_state=0,
          centers=[[1, 1], [-1, -1]],
          cluster_std=0.01,
      )
  
      n_neighbors = 2
      results = []
      for additional_neighbors in [0, 10]:
          nn = NearestNeighbors(
              n_neighbors=n_neighbors + additional_neighbors
          ).fit(X)
          graph = nn.kneighbors_graph(X, mode="connectivity")
          labels = (
              SpectralClustering(
                  random_state=0,
                  n_clusters=2,
                  affinity="precomputed_nearest_neighbors",
                  n_neighbors=n_neighbors,
              )
              .fit(graph)
              .labels_
          )
          results.append(labels)
  
      assert_array_equal(results[0], results[1])
  
imports: import pickle
  import re
  import numpy
  import pytest
  from scipy.linalg import LinAlgError
  from sklearn.cluster import SpectralClustering, spectral_clustering
  from sklearn.cluster._spectral import cluster_qr, discretize
  from sklearn.datasets import make_blobs
  from sklearn.feature_extraction import img_to_graph
  from sklearn.metrics import adjusted_rand_score
  from sklearn.metrics.pairwise import kernel_metrics, rbf_kernel
  from sklearn.neighbors import NearestNeighbors
  from sklearn.utils import check_random_state
  from sklearn.utils._testing import assert_array_equal
  from sklearn.utils.fixes import COO_CONTAINERS, CSR_CONTAINERS
label_desc: Use image node_id 3 for calling a global function with example usage: test_precomputed_nearest_neighbors_filtering() without return types