code: def to_dense_mt(vds: "VariantDataset") -> "MatrixTable":
      """Creates a single, dense :class:`.MatrixTable` from the split
      :class:`.VariantDataset` representation.
  
      Parameters
      ----------
      vds : :class:`.VariantDataset`
          Dataset in VariantDataset representation.
  
      Returns
      -------
      :class:`.MatrixTable`
          Dataset in dense MatrixTable representation.
      """
      ref = vds.reference_data
      # FIXME(chrisvittal) consider changing END semantics on VDS to make this better
      # see https://github.com/hail-is/hail/issues/13183 for why this is here and more discussion
      # we assume that END <= contig.length
      ref = ref.annotate_rows(
          _locus_global_pos=ref.locus.global_position(),
          _locus_pos=ref.locus.position,
      )
      ref = ref.transmute_entries(
          _END_GLOBAL=ref._locus_global_pos + (ref.END - ref._locus_pos)
      )
  
      to_drop = (
          "alleles",
          "rsid",
          "ref_allele",
          "_locus_global_pos",
          "_locus_pos",
      )
      ref = ref.drop(*(x for x in to_drop if x in ref.row))
      var = vds.variant_data
      refl = ref.localize_entries("_ref_entries")
      varl = var.localize_entries("_var_entries", "_var_cols")
      varl = varl.annotate(_variant_defined=True)
      joined = varl.key_by("locus").join(refl, how="outer")
      dr = joined.annotate(
          dense_ref=hl.or_missing(
              joined._variant_defined,
              hl.scan._densify(
                  hl.len(joined._var_cols), joined._ref_entries
              ),
          )
      )
      dr = dr.filter(dr._variant_defined)
  
      def coalesce_join(ref, var):
          call_field = "GT" if "GT" in var else "LGT"
          assert call_field in var, var.dtype
  
          shared_fields = [call_field] + list(
              f for f in ref.dtype if f in var.dtype
          )
          shared_field_set = set(shared_fields)
          var_fields = [
              f for f in var.dtype if f not in shared_field_set
          ]
  
          return hl.if_else(
              hl.is_defined(var),
              var.select(*shared_fields, *var_fields),
              ref.annotate(**{call_field: hl.call(0, 0)}).select(
                  *shared_fields,
                  **{f: hl.missing(var[f].dtype) for f in var_fields},
              ),
          )
  
      dr = dr.annotate(
          _dense=hl.rbind(
              dr._ref_entries,
              lambda refs_at_this_row: hl.enumerate(
                  hl.zip(dr._var_entries, dr.dense_ref)
              ).map(
                  lambda tup: coalesce_join(
                      hl.coalesce(
                          refs_at_this_row[tup[0]],
                          hl.or_missing(
                              tup[1][1]._END_GLOBAL
                              >= dr.locus.global_position(),
                              tup[1][1],
                          ),
                      ),
                      tup[1][0],
                  )
              ),
          ),
      )
  
      dr = dr._key_by_assert_sorted("locus", "alleles")
      fields_to_drop = [
          "_var_entries",
          "_ref_entries",
          "dense_ref",
          "_variant_defined",
      ]
  
      if hl.vds.VariantDataset.ref_block_max_length_field in dr.globals:
          fields_to_drop.append(
              hl.vds.VariantDataset.ref_block_max_length_field
          )
  
      if "ref_allele" in dr.row:
          fields_to_drop.append("ref_allele")
      dr = dr.drop(*fields_to_drop)
      return dr._unlocalize_entries(
          "_dense", "_var_cols", list(var.col_key)
      )
  
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 2 for calling a global function with example usage: to_dense_mt(vds) and returns: dr, hl