code: def test_blanczos_against_numpy():
      def concatToNumpy(blocks, horizontal=True):
          if horizontal:
              return np.concatenate(blocks, axis=0)
          else:
              return np.concatenate(blocks, axis=1)
  
      mt = hl.import_vcf(resource("tiny_m.vcf"))
      mt = mt.annotate_rows(
          AC=hl.agg.sum(mt.GT.n_alt_alleles()),
          n_called=hl.agg.count_where(hl.is_defined(mt.GT)),
      )
      n_rows = 3
      n_cols = 4
      k = 3
  
      mean = mt.AC / mt.n_called
      float_expr = hl.coalesce(
          (mt.GT.n_alt_alleles() - mean)
          / hl.sqrt(mean * (2 - mean) * n_rows / 2),
          0,
      )
  
      eigens, scores_t, loadings_t = hl._blanczos_pca(
          float_expr, k=k, q_iterations=7, compute_loadings=True
      )
      A = np.array(float_expr.collect()).reshape((3, 4)).T
      scores_blocks = scores_t.scores.collect()
      scores = concatToNumpy(scores_blocks)
      scores = np.reshape(scores, (len(scores) // k, k))
  
      loadings_blocks = loadings_t.loadings.collect()
      loadings = concatToNumpy(loadings_blocks)
      loadings = np.reshape(loadings, (len(loadings) // k, k))
  
      assert len(eigens) == 3
      assert len(scores) == n_cols
      assert len(loadings) == n_rows
      np.testing.assert_almost_equal(A @ loadings, scores)
  
      assert len(scores_t.globals) == 0
      assert len(loadings_t.globals) == 0
  
      # compute PCA with numpy
      def normalize(a):
          ms = np.mean(a, axis=0, keepdims=True)
          return np.divide(
              np.subtract(a, ms),
              np.sqrt(
                  2.0 * np.multiply(ms / 2.0, 1 - ms / 2.0) * a.shape[1]
              ),
          )
  
      g = np.pad(
          np.diag([1.0, 1, 2]), ((0, 1), (0, 0)), mode="constant"
      )
      g[1, 0] = 1.0 / 3
      n = normalize(g)
      U, s, V = np.linalg.svd(n, full_matrices=0)
      np_loadings = V.transpose()
      np_eigenvalues = np.multiply(s, s)
  
      def bound(
          vs, us
      ):  # equation 12 from https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4827102/pdf/main.pdf
          return (
              1
              / k
              * sum([np.linalg.norm(us.T @ vs[:, i]) for i in range(k)])
          )
  
      np.testing.assert_allclose(eigens, np_eigenvalues, rtol=0.05)
      assert bound(np_loadings, loadings) > 0.9
  
imports: import math
  import pytest
  import numpy
  import hail
  from hail.methods.pca import _make_tsm
  from ..helpers import resource, fails_local_backend, skip_when_service_backend, test_timeout
label_desc: Use image node_id 3 for calling a global function with example usage: test_blanczos_against_numpy() and returns: np, unknown, np, np