code: def get_allele_frequency(variant, index):
      """Gets allele frequency of the index-th alt_base of a Variant proto.
  
      Args:
        variant: A Variant proto.
        index: The index where we want to query allele frequency.
  
      Returns:
        A float. The queried allele frequency.
  
      Raises:
        ValueError: If the Variant proto does not include 'AF' field or the 'AF'
          field encounters an out-of-bound error when querying at position `index`
      """
      if variant.info.get("AF"):
          if index < len(variant.info["AF"].values):
              return variant.info["AF"].values[index].number_value
          else:
              raise ValueError(
                  "Invalid index",
                  index,
                  "for the info[AF] field",
                  variant.info["AF"].values,
              )
      raise ValueError("Variant does not have an AF field")
  
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 1 for calling a global function with example usage: get_allele_frequency(variant, index) and returns: variant