code: def hwe_normalize(call_expr):
      mt = matrix_table_source("hwe_normalize/call_expr", call_expr)
      mt = mt.select_entries(__gt=call_expr.n_alt_alleles())
      mt = mt.annotate_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))
  
      n_variants = mt.count_rows()
      if n_variants == 0:
          raise FatalError(
              "hwe_normalize: found 0 variants after filtering out monomorphic sites."
          )
      info(
          f"hwe_normalize: found {n_variants} variants after filtering out monomorphic sites."
      )
  
      mt = mt.annotate_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) * n_variants / 2
          )
      )
      mt = mt.unfilter_entries()
  
      normalized_gt = hl.or_else(
          (mt.__gt - mt.__mean_gt) / mt.__hwe_scaled_std_dev, 0.0
      )
      return normalized_gt
  
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 1 for calling a global function with example usage: hwe_normalize(call_expr) and returns: normalized_gt