code: def spectral(
      A,
      n_components=2,
      tol=1e-4,
      max_iter=None,
      random_state=None,
      verbose=False,
      add_jitter=True,
  ):
      """Initialize an embedding using the spectral embedding of the KNN graph.
  
      Specifically, we initialize data points by computing the diffusion map on
      the random walk transition matrix of the weighted graph given by the affiniy
      matrix.
  
      Parameters
      ----------
      A: Union[sp.csr_matrix, sp.csc_matrix, ...]
          The graph adjacency matrix.
  
      n_components: int
          The dimension of the embedding space.
  
      tol: float
          See scipy.sparse.linalg.eigsh documentation.
  
      max_iter: float
          See scipy.sparse.linalg.eigsh documentation.
  
      random_state: Any
          If the value is an int, random_state is the seed used by the random
          number generator. If the value is a RandomState instance, then it will
          be used as the random number generator. If the value is None, the random
          number generator is the RandomState instance used by `np.random`.
  
      add_jitter: bool
          If True, jitter with small standard deviation is added to the
          initialization to prevent points overlapping exactly, which may lead to
          numerical issues during optimization.
  
      verbose: bool
  
      Returns
      -------
      initialization: np.ndarray
  
      """
      if A.ndim != 2:
          raise ValueError(
              "The graph adjacency matrix must be a 2-dimensional matrix."
          )
      if A.shape[0] != A.shape[1]:
          raise ValueError(
              "The graph adjacency matrix must be a square matrix."
          )
  
      timer = utils.Timer(
          "Calculating spectral initialization...", verbose
      )
      timer.__enter__()
  
      D = sp.diags(np.ravel(np.sum(A, axis=1)))
  
      # Find leading eigenvectors
      k = n_components + 1
      # v0 initializatoin is taken from sklearn.utils._arpack._init_arpack_v0()
      random_state = check_random_state(random_state)
      v0 = random_state.uniform(-1, 1, A.shape[0])
      eigvals, eigvecs = sp.linalg.eigsh(
          A, M=D, k=k, tol=tol, maxiter=max_iter, which="LM", v0=v0
      )
      # Sort the eigenvalues in decreasing order
      order = np.argsort(eigvals)[::-1]
      eigvecs = eigvecs[:, order]
  
      # In diffusion maps, we multiply the eigenvectors by their eigenvalues
      eigvecs *= eigvals
  
      # Drop the leading eigenvector
      embedding = eigvecs[:, 1:]
  
      rescale(embedding, inplace=True)
      if add_jitter:
          jitter(embedding, inplace=True, random_state=random_state)
  
      timer.__exit__()
  
      return embedding
  
file_path: openTSNE/openTSNE/initialization.py
imports: import numpy
  import scipy.sparse
  from sklearn.decomposition import PCA
  from sklearn.utils import check_random_state
  from openTSNE import utils
label_desc: Use image node_id 5 for calling a global function with example usage: spectral(A, n_components, tol, max_iter, random_state, verbose, add_jitter) and returns: embedding