code: def test_table_key_by_aggregate():
      hl.reset_global_randomness()
      ht = hl.utils.range_table(5)
      ht = ht.annotate(x=hl.rand_int32(5))
      ht = ht.group_by(ht.x).aggregate(y=hl.agg.count())
      expected = [
          hl.Struct(x=2, y=1),
          hl.Struct(x=3, y=3),
          hl.Struct(x=4, y=1),
      ]
      actual = ht.collect()
      assert expected == actual
  
imports: import hail
  from .helpers import qobtest
label_desc: Use image node_id 6 for calling a global function with example usage: test_table_key_by_aggregate() without return types