code: def add_allele_frequencies_to_candidates(
      candidates, population_vcf_reader, ref_reader
  ):
      """Adds allele frequencies for candidate variants.
  
      Args:
        candidates: Iterable of DeepVariantCall protos that are the candidates we
          want to process.
        population_vcf_reader: A VcfReader object that reads the associated
          population VCF file for candidates. None if the contig is not found.
        ref_reader: A fasta.IndexedFastaReader.
  
      Yields:
        DeepVariantCall protos. The same set of input candidates, with field
          allele_frequency filled.
      """
      for candidate in candidates:
          if population_vcf_reader:
              dict_allele_frequency = find_matching_allele_frequency(
                  variant=candidate.variant,
                  population_vcf_reader=population_vcf_reader,
                  ref_reader=ref_reader,
              )
          else:
              # Set ALT frequencies to 0 if population_vcf_reader is None.
              dict_allele_frequency = {}
              dict_allele_frequency[
                  candidate.variant.reference_bases
              ] = 1
              for alt in candidate.variant.alternate_bases:
                  dict_allele_frequency[alt] = 0
  
          yield deepvariant_pb2.DeepVariantCall(
              variant=candidate.variant,
              allele_support=candidate.allele_support,
              allele_frequency=dict_allele_frequency,
          )
  
file_path: deepvariant/deepvariant/allele_frequency.py
imports: import collections
  from typing import DefaultDict, Sequence, Optional
  from absl import logging
  from third_party.nucleus.io import vcf
  from third_party.nucleus.util import ranges
  from third_party.nucleus.util import variant_utils
  from deepvariant.protos import deepvariant_pb2
label_desc: Use image node_id 8 for calling a global function with example usage: add_allele_frequencies_to_candidates(candidates, population_vcf_reader, ref_reader) without return types