code: def _spectral_moments(
      A, num_moments, p=None, moment_samples=500, block_size=128
  ):
      if not isinstance(A, TallSkinnyMatrix):
          raise_unless_entry_indexed("_spectral_moments/entry_expr", A)
          A = _make_tsm(A, block_size)
  
      n = A.ncols
  
      if p is None:
          p = min(num_moments // 2, 10)
  
      # TODO: When moment_samples > n, we should just do a TSQR on A, and compute
      # the spectrum of R.
      assert (
          moment_samples < n
      ), "_spectral_moments: moment_samples must be smaller than num cols of A"
      G = hl.rand_unif(-1, 1, size=(n, moment_samples)).map(
          lambda x: hl.sign(x)
      )
      Q1, R1 = hl.nd.qr(G)._persist()
      fact = _krylov_factorization(A, Q1, p, compute_U=False)
      moments_and_stdevs = hl.eval(
          fact.spectral_moments(num_moments, R1)
      )
      moments = moments_and_stdevs.moments
      stdevs = moments_and_stdevs.stdevs
      return moments, stdevs
  
imports: from typing import List, Tuple
  import hail
  import hail.expr.aggregators
  from hail.expr.expressions import construct_expr
  from hail.expr import expr_float64, expr_call, raise_unless_entry_indexed, matrix_table_source
  from hail import ir
  from hail.table import Table
  from hail.typecheck import typecheck, oneof, nullable
  from hail.utils import FatalError
  from hail.utils.java import Env, info
  from hail.experimental import mt_to_table_of_ndarray
label_desc: Use image node_id 8 for calling a global function with example usage: _spectral_moments(A, num_moments, p, moment_samples, block_size) and returns: moments,  stdevs