code: def summarize_variants(
      mt: Union[MatrixTable, MatrixTable], show=True, *, handler=None
  ):
      """Summarize the variants present in a dataset and print the results.
  
      Examples
      --------
      >>> hl.summarize_variants(dataset)  # doctest: +SKIP
      ==============================
      Number of variants: 346
      ==============================
      Alleles per variant
      -------------------
        2 alleles: 346 variants
      ==============================
      Variants per contig
      -------------------
        20: 346 variants
      ==============================
      Allele type distribution
      ------------------------
              SNP: 301 alleles
         Deletion: 27 alleles
        Insertion: 18 alleles
      ==============================
  
      Parameters
      ----------
      mt : :class:`.MatrixTable` or :class:`.Table`
          Matrix table with a variant (locus / alleles) row key.
      show : :obj:`bool`
          If ``True``, print results instead of returning them.
      handler
  
      Notes
      -----
      The result returned if `show` is ``False`` is a  :class:`.Struct` with
      five fields:
  
      - `n_variants` (:obj:`int`): Number of variants present in the matrix table.
      - `allele_types` (:obj:`dict` [:obj:`str`, :obj:`int`]): Number of alternate alleles in
        each allele allele category.
      - `contigs` (:obj:`dict` [:obj:`str`, :obj:`int`]): Number of variants on each contig.
      - `allele_counts` (:obj:`dict` [:obj:`int`, :obj:`int`]): Number of variants broken down
        by number of alleles (biallelic is 2, for example).
      - `r_ti_tv` (:obj:`float`): Ratio of transition alternate alleles to
        transversion alternate alleles.
  
      Returns
      -------
      :obj:`None` or :class:`.Struct`
          Returns ``None`` if `show` is ``True``, or returns results as a struct.
      """
      require_row_key_variant(mt, "summarize_variants")
      if isinstance(mt, MatrixTable):
          ht = mt.rows()
      else:
          ht = mt
      allele_pairs = hl.range(1, hl.len(ht.alleles)).map(
          lambda i: (ht.alleles[0], ht.alleles[i])
      )
  
      def explode_result(alleles):
          ref, alt = alleles
          return (
              hl.agg.counter(hl.allele_type(ref, alt)),
              hl.agg.count_where(hl.is_transition(ref, alt)),
              hl.agg.count_where(hl.is_transversion(ref, alt)),
          )
  
      (
          (allele_types, nti, ntv),
          contigs,
          allele_counts,
          n_variants,
      ) = ht.aggregate(
          (
              hl.agg.explode(explode_result, allele_pairs),
              hl.agg.counter(ht.locus.contig),
              hl.agg.counter(hl.len(ht.alleles)),
              hl.agg.count(),
          )
      )
      rg = ht.locus.dtype.reference_genome
      if show:
          summary = _VariantSummary(
              rg,
              n_variants,
              allele_counts,
              contigs,
              allele_types,
              nti,
              ntv,
          )
          if handler is None:
              handler = hl.utils.default_handler()
          handler(summary)
      else:
          return hl.Struct(
              allele_types=allele_types,
              contigs=contigs,
              allele_counts=allele_counts,
              n_variants=n_variants,
              r_ti_tv=nti / ntv,
          )
  
imports: import abc
  import logging
  import hail
  from collections import Counter
  import os
  from shlex import quote
  from typing import Dict, Tuple, List, Optional, Union
  from hailtop import pip_version
  from hailtop.utils import async_to_blocking
  import hailtop.batch_client
  from hailtop.config import get_deploy_config
  from hailtop import yamlx
  from hail.backend.service_backend import ServiceBackend
  from hail.typecheck import typecheck, oneof, anytype, nullable, numeric
  from hail.expr.expressions.expression_typecheck import expr_float64
  from hail.utils import FatalError
  from hail.utils.java import Env, info, warning
  from hail.utils.misc import divide_null, guess_cloud_spark_provider, new_temp_file
  from hail.matrixtable import MatrixTable
  from hail.table import Table
  from hail.ir import TableToTableApply
  from .misc import require_biallelic, require_row_key_variant, require_col_key_str, require_table_key_variant, require_alleles_field
label_desc: Use image node_id 8 for calling a global function with example usage: summarize_variants(mt, show) and returns: hl,  hl,  hl, hl