code: def find_matching_allele_frequency(
      variant, population_vcf_reader, ref_reader, padding_bases=0
  ):
      """Finds the allele frequencies of all the alt alleles for a candidate.
  
      Args:
        variant: A Variant proto generated by make_examples. Note that it can be
          multi-allelic.
        population_vcf_reader: A VcfReader object that reads associated VCF file for
          a candidate. We want to extract allele frequency information in the VCF.
        ref_reader: A IndexedFastaReader object that reads the reference FASTA.
        padding_bases: An integer that specifies the number of padding bases added
          when performing a VCF query. By default it is set to 0.
  
      Returns:
        A dict with alleles as keys, and allele frequencies as values
      """
      query_region = ranges.make_range(
          chrom=variant.reference_name,
          start=variant.start - padding_bases,
          end=variant.end + padding_bases,
      )
      # Convert to list because we'll look through cohort_variants more than once.
      cohort_variants = list(population_vcf_reader.query(query_region))
  
      # Init allele frequency dict using alt bases in the candidate.
      dict_allele_frequency = {}
      for alt_base in variant.alternate_bases:
          dict_allele_frequency[alt_base] = 0
  
      try:
          (
              reference_haplotype,
              reference_offset,
          ) = get_ref_haplotype_and_offset(
              variant, cohort_variants, ref_reader
          )
      except ValueError:
          # If the range associated with variant and cohort_variants is invalid,
          # assume this candidate does not have any ALT alleles.
          dict_allele_frequency = {}
          dict_allele_frequency[variant.reference_bases] = 1
          for alt in variant.alternate_bases:
              dict_allele_frequency[alt] = 0
          return dict_allele_frequency
  
      candidate_haps = update_haplotype(
          variant, reference_haplotype, reference_offset
      )
      cohort_haps = []
      for cohort_variant in cohort_variants:
          cohort_haps.extend(
              update_haplotype(
                  cohort_variant, reference_haplotype, reference_offset
              )
          )
  
      for c in candidate_haps:
          logging.debug("candidate %s, %s", c["haplotype"], c["alt"])
      for c in cohort_haps:
          logging.debug("cohort    %s, %s", c["haplotype"], c["alt"])
  
      dict_allele_frequency = match_candidate_and_cohort_haplotypes(
          candidate_haps, cohort_haps
      )
  
      if dict_allele_frequency:
          logging.vlog(
              3,
              "dict_allele_frequency: %s:%d-%d, %s > %s",
              variant.reference_name,
              variant.start,
              variant.end,
              variant.reference_bases,
              dict_allele_frequency,
          )
  
      return 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 6 for calling a global function with example usage: find_matching_allele_frequency(variant, population_vcf_reader, ref_reader, padding_bases) and returns: dict_allele_frequency, dict_allele_frequency