code: def all_diploid_haplotypes(
      variants_and_genotypes, genotypes2haplotype
  ):
      """Returns all diploid haplotypes for variants given their genotypes."""
  
      def complement_haploid_genotype(haploid_genotype, genotypes):
          assert len(haploid_genotype) == len(genotypes)
          return tuple(
              g1[1] if hg1 == g1[0] and len(g1) == 2 else g1[0]
              for hg1, g1 in zip(haploid_genotype, genotypes)
          )
  
      genotypes = [vg.genotypes for vg in variants_and_genotypes]
      generated_already = set()
      for haploid_genotype, haplotype in genotypes2haplotype.items():
          complement = complement_haploid_genotype(
              haploid_genotype, genotypes
          )
          complement_haplotype = genotypes2haplotype.get(
              complement, None
          )
          if (
              complement_haplotype is not None
              and complement not in generated_already
          ):
              generated_already.add(haploid_genotype)
              yield {haplotype, complement_haplotype}
  
imports: import collections
  import copy
  import enum
  import heapq
  import itertools
  from absl import logging
  from deepvariant.labeler import variant_labeler
  from deepvariant.protos import deepvariant_pb2
  from third_party.nucleus.io import fasta
  from third_party.nucleus.util import ranges
  from third_party.nucleus.util import variant_utils
  from third_party.nucleus.util import variantcall_utils
label_desc: Use image node_id 5 for calling a global function with example usage: all_diploid_haplotypes(variants_and_genotypes, genotypes2haplotype) and returns: tuple