code: def _blanczos_pca(
      A,
      k=10,
      compute_loadings=False,
      q_iterations=10,
      oversampling_param=None,
      block_size=128,
      compute_scores=True,
      transpose=False,
  ):
      r"""Run randomized principal component analysis approximation (PCA)
      on numeric columns derived from a matrix table.
  
      Implements the Blanczos algorithm found by Rokhlin, Szlam, and Tygert.
  
      Examples
      --------
  
      For a matrix table with variant rows, sample columns, and genotype entries,
      compute the top 2 PC sample scores and eigenvalues of the matrix of 0s and
      1s encoding missingness of genotype calls.
  
      >>> eigenvalues, scores, _ = hl._blanczos_pca(hl.int(hl.is_defined(dataset.GT)),
      ...                                 k=2)
  
      Warning
      -------
        This method does **not** automatically mean-center or normalize each column.
        If desired, such transformations should be incorporated in `entry_expr`.
  
        Hail will return an error if `entry_expr` evaluates to missing, nan, or
        infinity on any entry.
  
      Notes
      -----
  
      PCA is run on the columns of the numeric matrix obtained by evaluating
      `entry_expr` on each entry of the matrix table, or equivalently on the rows
      of the **transposed** numeric matrix :math:`M` referenced below.
  
      PCA computes the SVD
  
      .. math::
  
        M = USV^T
  
      where columns of :math:`U` are left singular vectors (orthonormal in
      :math:`\mathbb{R}^n`), columns of :math:`V` are right singular vectors
      (orthonormal in :math:`\mathbb{R}^m`), and :math:`S=\mathrm{diag}(s_1, s_2,
      \ldots)` with ordered singular values :math:`s_1 \ge s_2 \ge \cdots \ge 0`.
      Typically one computes only the first :math:`k` singular vectors and values,
      yielding the best rank :math:`k` approximation :math:`U_k S_k V_k^T` of
      :math:`M`; the truncations :math:`U_k`, :math:`S_k` and :math:`V_k` are
      :math:`n \times k`, :math:`k \times k` and :math:`m \times k`
      respectively.
  
      From the perspective of the rows of :math:`M` as samples (data points),
      :math:`V_k` contains the loadings for the first :math:`k` PCs while
      :math:`MV_k = U_k S_k` contains the first :math:`k` PC scores of each
      sample. The loadings represent a new basis of features while the scores
      represent the projected data on those features. The eigenvalues of the Gramian
      :math:`MM^T` are the squares of the singular values :math:`s_1^2, s_2^2,
      \ldots`, which represent the variances carried by the respective PCs. By
      default, Hail only computes the loadings if the ``loadings`` parameter is
      specified.
  
      Scores are stored in a :class:`.Table` with the column key of the matrix
      table as key and a field `scores` of type ``array<float64>`` containing
      the principal component scores.
  
      Loadings are stored in a :class:`.Table` with the row key of the matrix
      table as key and a field `loadings` of type ``array<float64>`` containing
      the principal component loadings.
  
      The eigenvalues are returned in descending order, with scores and loadings
      given the corresponding array order.
  
      Parameters
      ----------
      entry_expr : :class:`.Expression`
          Numeric expression for matrix entries.
      k : :obj:`int`
          Number of principal components.
      compute_loadings : :obj:`bool`
          If ``True``, compute row loadings.
      q_iterations : :obj:`int`
          Number of rounds of power iteration to amplify singular values.
      oversampling_param : :obj:`int`
          Amount of oversampling to use when approximating the singular values.
          Usually a value between `0 <= oversampling_param <= k`.
  
      Returns
      -------
      (:obj:`list` of :obj:`float`, :class:`.Table`, :class:`.Table`)
          List of eigenvalues, table with column scores, table with row loadings.
      """
      if not isinstance(A, TallSkinnyMatrix):
          raise_unless_entry_indexed("_blanczos_pca/entry_expr", A)
          A = _make_tsm(A, block_size)
  
      if oversampling_param is None:
          oversampling_param = k
  
      compute_U = (not transpose and compute_loadings) or (
          transpose and compute_scores
      )
      U, S, V = _reduced_svd(
          A, k, compute_U, q_iterations, k + oversampling_param
      )
      info("blanczos_pca: SVD Complete. Computing conversion to PCs.")
  
      def numpy_to_rows_table(X, field_name):
          t = A.source_table.select()
          t = t.annotate_globals(X=X)
          idx_name = "_tmp_pca_loading_index"
          t = t.add_index(idx_name)
          t = t.annotate(
              **{field_name: hl.array(t.X[t[idx_name], :])}
          ).select_globals()
          t = t.drop(t[idx_name])
          return t
  
      def numpy_to_cols_table(X, field_name):
          hail_array = X._data_array()
          cols_and_X = hl.zip(
              A.source_table.index_globals().cols, hail_array
          ).map(lambda tup: tup[0].annotate(**{field_name: tup[1]}))
          t = hl.Table.parallelize(cols_and_X, key=A.col_key)
          return t
  
      st = None
      lt = None
      eigens = hl.eval(S * S)
      if transpose:
          if compute_loadings:
              lt = numpy_to_cols_table(V, "loadings")
          if compute_scores:
              st = numpy_to_rows_table(U * S, "scores")
      else:
          if compute_scores:
              st = numpy_to_cols_table(V * S, "scores")
          if compute_loadings:
              lt = numpy_to_rows_table(U, "loadings")
  
      return eigens, st, lt
  
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 10 for calling a global function with example usage: _blanczos_pca(A, k, compute_loadings, q_iterations, oversampling_param, block_size, compute_scores, transpose) and returns: eigens,  st,  lt, t, t