code: def test_spectral_clustering():
      # Test chaining KNeighborsTransformer and SpectralClustering
      n_neighbors = 5
      X, _ = make_blobs(random_state=0)
  
      # compare the chained version and the compact version
      est_chain = make_pipeline(
          KNeighborsTransformer(
              n_neighbors=n_neighbors, mode="connectivity"
          ),
          SpectralClustering(
              n_neighbors=n_neighbors,
              affinity="precomputed",
              random_state=42,
          ),
      )
      est_compact = SpectralClustering(
          n_neighbors=n_neighbors,
          affinity="nearest_neighbors",
          random_state=42,
      )
      labels_compact = est_compact.fit_predict(X)
      labels_chain = est_chain.fit_predict(X)
      assert_array_almost_equal(labels_chain, labels_compact)
  
file_path: scikit-learn/sklearn/neighbors/tests/test_neighbors_pipeline.py
imports: import numpy
  from sklearn.base import clone
  from sklearn.cluster import DBSCAN, SpectralClustering
  from sklearn.cluster.tests.common import generate_clustered_data
  from sklearn.datasets import make_blobs
  from sklearn.manifold import TSNE, Isomap, SpectralEmbedding
  from sklearn.neighbors import KNeighborsRegressor, KNeighborsTransformer, LocalOutlierFactor, RadiusNeighborsRegressor, RadiusNeighborsTransformer
  from sklearn.pipeline import make_pipeline
  from sklearn.utils._testing import assert_array_almost_equal
label_desc: Use image node_id 1 for calling a global function with example usage: test_spectral_clustering() without return types