code: def test_merge_reference_blocks():
      vds = hl.vds.read_vds(
          os.path.join(resource("vds"), "1kg_chr22_5_samples.vds")
      )
      vds = hl.vds.filter_samples(vds, ["HG00187"])
      rd = vds.reference_data
      vds.reference_data = rd.annotate_entries(GQ=rd.GQ - rd.GQ % 10)
      vds.reference_data = vds.reference_data.annotate_entries(
          LEN=vds.reference_data.END
          - vds.reference_data.locus.position
          + 1,
          N_BLOCKS=1,
      )
      sampqc_1 = hl.vds.sample_qc(
          vds, gq_bins=(0, 10, 20, 30), dp_bins=()
      ).select("bases_over_gq_threshold")
  
      merged = hl.vds.merge_reference_blocks(
          vds,
          equivalence_function=lambda b1, b2: b1.GQ == b2.GQ,
          merge_functions={
              "LEN": "sum",
              "MIN_DP": "min",
              "N_BLOCKS": "sum",
          },
      ).checkpoint(new_temp_file(extension="vds"))
      sampqc_2 = hl.vds.sample_qc(
          merged, gq_bins=(0, 10, 20, 30), dp_bins=()
      ).select("bases_over_gq_threshold")
  
      assert sampqc_1._same(sampqc_2), "gq bins aren't the same"
  
      mrd = merged.reference_data
      n_blocks_original = vds.reference_data.entries().count()
      (n_blocks_merged, sum_n) = mrd.aggregate_entries(
          (hl.agg.count(), hl.agg.sum(mrd.N_BLOCKS))
      )
  
      assert n_blocks_original == sum_n
      assert mrd.aggregate_entries(
          hl.agg.all(mrd.LEN == mrd.END - mrd.locus.position + 1)
      )
      assert hl.vds.to_dense_mt(vds)._same(hl.vds.to_dense_mt(merged))
  
imports: import os
  import pytest
  import hail
  from hail.utils import new_temp_file
  from hail.vds.combiner.combine import defined_entry_fields
  from ..helpers import resource, test_timeout, qobtest
label_desc: Use image node_id 22 for calling a global function with example usage: test_merge_reference_blocks() without return types