code: def _genotype_order_in_likelihoods(num_alts, ploidy=2):
      """Yields tuples of `ploidy` ints for the given number of alt alleles.
  
      https://samtools.github.io/hts-specs/VCFv4.1.pdf
      "If A is the allele in REF and B,C,... are the alleles as ordered in ALT,
      the ordering of genotypes for the likelihoods is given by:
      F(j/k) = (k*(k+1)/2)+j. In other words, for biallelic sites the ordering is:
      AA,AB,BB; for triallelic sites the ordering is: AA,AB,BB,AC,BC,CC, etc."
      The biallelic sites in our case are 0/0, 0/1, 1/1.
      The triallelic sites are 0/0, 0/1, 1/1, 0/2, 1/2, 2/2.
      This wiki page has more information that generalizes to different ploidy.
      http://genome.sph.umich.edu/wiki/Relationship_between_Ploidy,_Alleles_and_Genotypes
  
      Args:
        num_alts: int. The number of alternate alleles at the site.
        ploidy: int. The ploidy for which to return genotypes.
  
      Yields:
        Tuples of `ploidy` ints representing allele indices in the order they appear
        in the corresponding genotype likelihood array.
      """
      if ploidy == 1:
          for i in range(num_alts + 1):
              yield (i,)
      elif ploidy == 2:
          for j in range(num_alts + 1):
              for i in range(j + 1):
                  yield (i, j)
      else:
          raise NotImplementedError(
              "Only haploid and diploid supported."
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import enum
  import itertools
  import six
  from third_party.nucleus.protos import variants_pb2
  from third_party.nucleus.util import ranges
  from third_party.nucleus.util import variantcall_utils
  from third_party.nucleus.util import vcf_constants
label_desc: Use image node_id 33 for calling a global function with example usage: _genotype_order_in_likelihoods(num_alts, ploidy) without return types