code: def interval_coverage(
      vds: VariantDataset,
      intervals: hl.Table,
      gq_thresholds=(
          0,
          10,
          20,
      ),
      dp_thresholds=(0, 1, 10, 20, 30),
      dp_field=None,
  ) -> "MatrixTable":
      """Compute statistics about base coverage by interval.
  
      Returns a :class:`.MatrixTable` with interval row keys and sample column keys.
  
      Contains the following row fields:
       - ``interval`` (*interval*): Genomic interval of interest.
       - ``interval_size`` (*int32*): Size of interval, in bases.
  
  
      Computes the following entry fields:
  
       -  ``bases_over_gq_threshold`` (*tuple of int64*): Number of bases in the interval
          over each GQ threshold.
       -  ``fraction_over_gq_threshold`` (*tuple of float64*): Fraction of interval (in bases)
          above each GQ threshold. Computed by dividing each member of *bases_over_gq_threshold*
          by *interval_size*.
       -  ``bases_over_dp_threshold`` (*tuple of int64*): Number of bases in the interval
          over each DP threshold.
       -  ``fraction_over_dp_threshold`` (*tuple of float64*): Fraction of interval (in bases)
          above each DP threshold. Computed by dividing each member of *bases_over_dp_threshold*
          by *interval_size*.
       -  ``sum_dp`` (*int64*): Sum of depth values by base across the interval.
       -  ``mean_dp`` (*float64*): Mean depth of bases across the interval. Computed by dividing
          *sum_dp* by *interval_size*.
  
      If the `dp_field` parameter is not specified, the ``DP`` is used for depth
      if present. If no ``DP`` field is present, the ``MIN_DP`` field is used. If no ``DP``
      or ``MIN_DP`` field is present, no depth statistics will be calculated.
  
      Note
      ----
      The metrics computed by this method are computed **only from reference blocks**. Most
      variant callers produce data where non-reference calls interrupt reference blocks, and
      so the metrics computed here are slight underestimates of the true values (which would
      include the quality/depth of non-reference calls). This is likely a negligible difference,
      but is something to be aware of, especially as it interacts with samples of
      ancestral backgrounds with more or fewer non-reference calls.
  
      Parameters
      ----------
      vds : :class:`.VariantDataset`
      intervals : :class:`.Table`
          Table of intervals. Must be start-inclusive, and cannot span contigs.
      gq_thresholds : tuple of int
          GQ thresholds.
      dp_field : str, optional
          Field for depth calculation. Uses DP or MIN_DP by default (with priority for DP if present).
  
      Returns
      -------
      :class:`.MatrixTable`
          Interval-by-sample matrix
      """
      ref = vds.reference_data
      split = segment_reference_blocks(ref, intervals)
      intervals = intervals.annotate(interval_dup=intervals.key[0])
  
      if "DP" in ref.entry:
          dp_field_to_use = "DP"
      elif "MIN_DP" in ref.entry:
          dp_field_to_use = "MIN_DP"
      else:
          dp_field_to_use = dp_field
  
      ref_block_length = split.END - split.locus.position + 1
      if dp_field_to_use is not None:
          dp = split[dp_field_to_use]
          dp_field_dict = {
              "sum_dp": hl.agg.sum(ref_block_length * dp),
              "bases_over_dp_threshold": tuple(
                  hl.agg.filter(
                      dp >= dp_threshold, hl.agg.sum(ref_block_length)
                  )
                  for dp_threshold in dp_thresholds
              ),
          }
      else:
          dp_field_dict = dict()
  
      per_interval = split.group_rows_by(
          interval=intervals[split.row_key[0]].interval_dup
      ).aggregate(
          bases_over_gq_threshold=tuple(
              hl.agg.filter(
                  split.GQ >= gq_threshold, hl.agg.sum(ref_block_length)
              )
              for gq_threshold in gq_thresholds
          ),
          **dp_field_dict,
      )
  
      interval = per_interval.interval
      interval_size = (
          interval.end.position
          + interval.includes_end
          - interval.start.position
          - 1
          + interval.includes_start
      )
      per_interval = per_interval.annotate_rows(
          interval_size=interval_size
      )
  
      dp_mod_dict = {}
      if dp_field_to_use is not None:
          dp_mod_dict["fraction_over_dp_threshold"] = tuple(
              hl.float(x) / per_interval.interval_size
              for x in per_interval.bases_over_dp_threshold
          )
          dp_mod_dict["mean_dp"] = (
              per_interval.sum_dp / per_interval.interval_size
          )
  
      per_interval = per_interval.annotate_entries(
          fraction_over_gq_threshold=tuple(
              hl.float(x) / per_interval.interval_size
              for x in per_interval.bases_over_gq_threshold
          ),
          **dp_mod_dict,
      )
  
      per_interval = per_interval.annotate_globals(
          gq_thresholds=hl.tuple(gq_thresholds)
      )
  
      return per_interval
  
imports: from typing import Sequence
  import hail
  from hail import ir
  from hail.expr import expr_any, expr_array, expr_interval, expr_locus, expr_str, expr_bool
  from hail.matrixtable import MatrixTable
  from hail.methods.misc import require_first_key_field_locus
  from hail.table import Table
  from hail.typecheck import sequenceof, typecheck, nullable, oneof, enumeration, func_spec, dictof
  from hail.utils.java import Env, info, warning
  from hail.utils.misc import divide_null, new_temp_file, wrap_to_list
  from hail.vds.variant_dataset import VariantDataset
label_desc: Use image node_id 14 for calling a global function with example usage: interval_coverage(vds, intervals, gq_thresholds, dp_thresholds, dp_field) and returns: per_interval