code: def test_randomized_eigsh_reconst_low_rank(n, rank):
      """Check that randomized_eigsh is able to reconstruct a low rank psd matrix
  
      Tests that the decomposition provided by `_randomized_eigsh` leads to
      orthonormal eigenvectors, and that a low rank PSD matrix can be effectively
      reconstructed with good accuracy using it.
      """
      assert rank < n
  
      # create a low rank PSD
      rng = np.random.RandomState(69)
      X = rng.randn(n, rank)
      A = X @ X.T
  
      # approximate A with the "right" number of components
      S, V = _randomized_eigsh(A, n_components=rank, random_state=rng)
      # orthonormality checks
      assert_array_almost_equal(
          np.linalg.norm(V, axis=0), np.ones(S.shape)
      )
      assert_array_almost_equal(V.T @ V, np.diag(np.ones(S.shape)))
      # reconstruction
      A_reconstruct = V @ np.diag(S) @ V.T
  
      # test that the approximation is good
      assert_array_almost_equal(A_reconstruct, A, decimal=6)
  
imports: import numpy
  import pytest
  from scipy import linalg, sparse
  from scipy.linalg import eigh
  from scipy.sparse.linalg import eigsh
  from scipy.special import expit
  from sklearn.datasets import make_low_rank_matrix, make_sparse_spd_matrix
  from sklearn.utils import gen_batches
  from sklearn.utils._arpack import _init_arpack_v0
  from sklearn.utils._testing import assert_allclose, assert_allclose_dense_sparse, assert_almost_equal, assert_array_almost_equal, assert_array_equal, skip_if_32bit
  from sklearn.utils.extmath import _deterministic_vector_sign_flip, _incremental_mean_and_var, _randomized_eigsh, _safe_accumulator_op, cartesian, density, log_logistic, randomized_svd, row_norms, safe_sparse_dot, softmax, stable_cumsum, svd_flip, weighted_mode
  from sklearn.utils.fixes import COO_CONTAINERS, CSC_CONTAINERS, CSR_CONTAINERS, DOK_CONTAINERS, LIL_CONTAINERS, _mode
label_desc: Use image node_id 7 for calling a global function with example usage: test_randomized_eigsh_reconst_low_rank(n, rank) without return types