code: def test_precomputed_nearest_neighbors_filtering():
      # Test precomputed graph filtering when containing too many neighbors
      n_neighbors = 2
      results = []
      for additional_neighbors in [0, 10]:
          nn = NearestNeighbors(
              n_neighbors=n_neighbors + additional_neighbors
          ).fit(S)
          graph = nn.kneighbors_graph(S, mode="connectivity")
          embedding = (
              SpectralEmbedding(
                  random_state=0,
                  n_components=2,
                  affinity="precomputed_nearest_neighbors",
                  n_neighbors=n_neighbors,
              )
              .fit(graph)
              .embedding_
          )
          results.append(embedding)
  
      assert_array_equal(results[0], results[1])
  
imports: from unittest.mock import Mock
  import numpy
  import pytest
  from scipy import sparse
  from scipy.linalg import eigh
  from scipy.sparse.linalg import eigsh, lobpcg
  from sklearn.cluster import KMeans
  from sklearn.datasets import make_blobs
  from sklearn.manifold import SpectralEmbedding, _spectral_embedding, spectral_embedding
  from sklearn.manifold._spectral_embedding import _graph_connected_component, _graph_is_connected
  from sklearn.metrics import normalized_mutual_info_score, pairwise_distances
  from sklearn.metrics.pairwise import rbf_kernel
  from sklearn.neighbors import NearestNeighbors
  from sklearn.utils._testing import assert_array_almost_equal, assert_array_equal
  from sklearn.utils.extmath import _deterministic_vector_sign_flip
  from sklearn.utils.fixes import COO_CONTAINERS, CSC_CONTAINERS, CSR_CONTAINERS, parse_version, sp_version
  from sklearn.utils.fixes import laplacian
label_desc: Use image node_id 5 for calling a global function with example usage: test_precomputed_nearest_neighbors_filtering() without return types