code: def _dominance_encoding(
      g: Float64Expression, mu: Float64Expression
  ) -> Float64Expression:
      """Compute value for a single entry in dominance encoding of genotype matrix,
      given the number of alternate alleles from the genotype matrix and the
      estimated individual-specific allele frequency.
  
      Parameters
      ----------
      g : :class:`.Float64Expression`
          Alternate allele count.
      mu : :class:`.Float64Expression`
          Estimated individual-specific allele frequency.
  
      Returns
      -------
      gd : :class:`.Float64Expression`
          Dominance-coded entry for dominance-coded genotype matrix.
      """
      gd = (
          hl.case()
          .when(hl.is_nan(mu), 0.0)
          .when(g == 0.0, mu)
          .when(g == 1.0, 0.0)
          .when(g == 2.0, 1 - mu)
          .or_error(
              "entries in genotype matrix must be 0.0, 1.0, or 2.0"
          )
      )
      return gd
  
imports: from typing import Optional
  import hail
  import hail.expr.aggregators
  from hail import ir
  from hail.backend.spark_backend import SparkBackend
  from hail.expr import ArrayNumericExpression, BooleanExpression, CallExpression, Float64Expression, analyze, expr_array, expr_call, expr_float64, matrix_table_source
  from hail.expr.types import tarray
  from hail.linalg import BlockMatrix
  from hail.table import Table
  from hail.typecheck import enumeration, nullable, numeric, typecheck
  from hail.utils import new_temp_file
  from hail.utils.java import Env
  from ..pca import _hwe_normalized_blanczos, hwe_normalized_pca
label_desc: Use image node_id 4 for calling a global function with example usage: _dominance_encoding(g, mu) and returns: gd