code: def genetic_relatedness_matrix(call_expr) -> BlockMatrix:
      r"""Compute the genetic relatedness matrix (GRM).
  
      Examples
      --------
  
      >>> grm = hl.genetic_relatedness_matrix(dataset.GT)
  
      Notes
      -----
      The genetic relationship matrix (GRM) :math:`G` encodes genetic correlation
      between each pair of samples. It is defined by :math:`G = MM^T` where
      :math:`M` is a standardized version of the genotype matrix, computed as
      follows. Let :math:`C` be the :math:`n \times m` matrix of raw genotypes
      in the variant dataset, with rows indexed by :math:`n` samples and columns
      indexed by :math:`m` bialellic autosomal variants; :math:`C_{ij}` is the
      number of alternate alleles of variant :math:`j` carried by sample
      :math:`i`, which can be 0, 1, 2, or missing. For each variant :math:`j`,
      the sample alternate allele frequency :math:`p_j` is computed as half the
      mean of the non-missing entries of column :math:`j`. Entries of :math:`M`
      are then mean-centered and variance-normalized as
  
      .. math::
  
          M_{ij} = \frac{C_{ij}-2p_j}{\sqrt{2p_j(1-p_j)m}},
  
      with :math:`M_{ij} = 0` for :math:`C_{ij}` missing (i.e. mean genotype
      imputation). This scaling normalizes genotype variances to a common value
      :math:`1/m` for variants in Hardy-Weinberg equilibrium and is further
      motivated in the paper `Patterson, Price and Reich, 2006
      <http://journals.plos.org/plosgenetics/article?id=10.1371/journal.pgen.0020190>`__.
      (The resulting amplification of signal from the low end of the allele
      frequency spectrum will also introduce noise for rare variants; common
      practice is to filter out variants with minor allele frequency below some
      cutoff.) The factor :math:`1/m` gives each sample row approximately unit
      total variance (assuming linkage equilibrium) so that the diagonal entries
      of the GRM are approximately 1. Equivalently,
  
      .. math::
  
          G_{ik} = \frac{1}{m} \sum_{j=1}^m \frac{(C_{ij}-2p_j)(C_{kj}-2p_j)}{2 p_j (1-p_j)}
  
      This method drops variants with :math:`p_j = 0` or :math:`p_j = 1` before
      computing kinship.
  
      Parameters
      ----------
      call_expr : :class:`.CallExpression`
          Entry-indexed call expression with columns corresponding
          to samples.
  
      Returns
      -------
      :class:`.BlockMatrix`
          Genetic relatedness matrix for all samples. Row and column indices
          correspond to matrix table column index.
      """
      mt = matrix_table_source(
          "genetic_relatedness_matrix/call_expr", call_expr
      )
      raise_unless_entry_indexed(
          "genetic_relatedness_matrix/call_expr", call_expr
      )
  
      mt = mt.select_entries(
          __gt=call_expr.n_alt_alleles()
      ).unfilter_entries()
      mt = mt.select_rows(
          __AC=agg.sum(mt.__gt),
          __n_called=agg.count_where(hl.is_defined(mt.__gt)),
      )
      mt = mt.filter_rows((mt.__AC > 0) & (mt.__AC < 2 * mt.__n_called))
  
      mt = mt.select_rows(__mean_gt=mt.__AC / mt.__n_called)
      mt = mt.annotate_rows(
          __hwe_scaled_std_dev=hl.sqrt(
              mt.__mean_gt * (2 - mt.__mean_gt)
          )
      )
  
      normalized_gt = hl.or_else(
          (mt.__gt - mt.__mean_gt) / mt.__hwe_scaled_std_dev, 0.0
      )
      bm = BlockMatrix.from_entry_expr(normalized_gt)
  
      return (bm.T @ bm) / (bm.n_rows / 2.0)
  
imports: import builtins
  import itertools
  import math
  from typing import Dict, Callable, Optional, Union, Tuple, List
  import hail
  import hail
  import hail.expr.aggregators
  from hail import ir
  from hail.expr import Expression, ExpressionException, expr_float64, expr_call, expr_any, expr_numeric, expr_locus, analyze, raise_unless_entry_indexed, raise_unless_row_indexed, matrix_table_source, table_source, raise_unless_column_indexed
  from hail.expr.types import tbool, tarray, tfloat64, tint32
  from hail.genetics.reference_genome import reference_genome_type
  from hail.linalg import BlockMatrix
  from hail.matrixtable import MatrixTable
  from hail.methods.misc import require_biallelic, require_row_key_variant
  from hail.stats import LinearMixedModel
  from hail.table import Table
  from hail.typecheck import typecheck, nullable, numeric, oneof, sized_tupleof, sequenceof, enumeration, anytype
  from hail.utils import wrap_to_list, new_temp_file, FatalError
  from hail.utils.java import Env, info, warning
  from .None import pca
  from .None import relatedness
  from ..backend.spark_backend import SparkBackend
label_desc: Use image node_id 28 for calling a global function with example usage: genetic_relatedness_matrix(call_expr) and returns: unknown