code: def phase_trio_matrix_by_transmission(
      tm: hl.MatrixTable,
      call_field: str = "GT",
      phased_call_field: str = "PBT_GT",
  ) -> hl.MatrixTable:
      """Adds a phased genoype entry to a trio MatrixTable based allele transmission in the trio.
  
      Example
      -------
      >>> # Create a trio matrix
      >>> pedigree = hl.Pedigree.read('data/case_control_study.fam')
      >>> trio_dataset = hl.trio_matrix(dataset, pedigree, complete_trios=True)
  
      >>> # Phase trios by transmission
      >>> phased_trio_dataset = phase_trio_matrix_by_transmission(trio_dataset)
  
      Notes
      -----
      Uses only a `Call` field to phase and only phases when all 3 members of the trio are present and have a call.
  
      In the phased genotypes, the order is as follows:
      - Proband: father_allele | mother_allele
      - Parents: transmitted_allele | untransmitted_allele
  
      Phasing of sex chromosomes:
      - Sex chromosomes of male individuals should be haploid to be phased correctly.
      - If a proband is diploid on non-par regions of the sex chromosomes, it is assumed to be female.
  
      Genotypes that cannot be phased are set to `NA`.
      The following genotype calls combinations cannot be phased by transmission (all trio members phased calls set to missing):
      1. One of the calls in the trio is missing
      2. The proband genotype cannot be obtained from the parents alleles (Mendelian violation)
      3. All individuals of the trio are heterozygous for the same two alleles
      4. Father is diploid on non-PAR region of X or Y
      5. Proband is diploid on non-PAR region of Y
  
      In addition, individual phased genotype calls are returned as missing in the following situations:
      1. All mother genotype calls non-PAR region of Y
      2. Diploid father genotype calls on non-PAR region of X for a male proband (proband and mother are still phased as father doesn't participate in allele transmission)
  
      Parameters
      ----------
      tm : :class:`.MatrixTable`
          Trio MatrixTable (entries have to be a Struct with `proband_entry`, `mother_entry` and `father_entry` present)
      call_field : str
          genotype field name in the matrix entries to use for phasing
      phased_call_field : str
          name for the phased genotype field in the matrix entries
  
      Returns
      -------
      :class:`.MatrixTable`
          Trio MatrixTable entry with additional phased genotype field for each individual
      """
  
      tm = tm.annotate_entries(
          __phased_GT=phase_by_transmission(
              tm.locus,
              tm.alleles,
              tm.proband_entry[call_field],
              tm.father_entry[call_field],
              tm.mother_entry[call_field],
          )
      )
  
      return tm.select_entries(
          proband_entry=hl.struct(
              **tm.proband_entry,
              **{phased_call_field: tm.__phased_GT[0]},
          ),
          father_entry=hl.struct(
              **tm.father_entry,
              **{phased_call_field: tm.__phased_GT[1]},
          ),
          mother_entry=hl.struct(
              **tm.mother_entry,
              **{phased_call_field: tm.__phased_GT[2]},
          ),
      )
  
imports: import hail
  from hail.typecheck import typecheck, sequenceof
  from hail.expr.expressions import expr_str, expr_call, expr_locus, expr_array
  from typing import List
label_desc: Use image node_id 2 for calling a global function with example usage: phase_trio_matrix_by_transmission(tm, call_field, phased_call_field) and returns: tm