code: def test_group_cols_by_aggregate(self):
      mt, mt2 = self.get_groupable_matrix2()
  
      col_result = (
          mt.group_cols_by(group=mt2.cols()[mt.col_idx].col_idx2 < 2)
          .aggregate_cols(collect=hl.agg.collect(mt.col_idx))
          .aggregate_cols(count=hl.agg.count())
          .aggregate_entries(
              sum=hl.agg.sum(mt2[mt.row_idx, mt.col_idx].x + mt.glob)
              + mt.glob
              - 15
              - mt.row_idx
          )  # tests fixed indices
          .aggregate_entries(x=5)
          .result()
      )
  
      col_expected = (
          hl.Table.parallelize(
              [
                  {
                      "group": True,
                      "row_idx": 0,
                      "sum": 1,
                      "collect": [0, 1],
                      "count": 2,
                      "r1": 3,
                      "x": 5,
                  },
                  {
                      "group": True,
                      "row_idx": 1,
                      "sum": 2,
                      "collect": [0, 1],
                      "count": 2,
                      "r1": 3,
                      "x": 5,
                  },
                  {
                      "group": True,
                      "row_idx": 2,
                      "sum": 3,
                      "collect": [0, 1],
                      "count": 2,
                      "r1": 3,
                      "x": 5,
                  },
                  {
                      "group": True,
                      "row_idx": 3,
                      "sum": 4,
                      "collect": [0, 1],
                      "count": 2,
                      "r1": 3,
                      "x": 5,
                  },
                  {
                      "group": False,
                      "row_idx": 0,
                      "sum": 5,
                      "collect": [2, 3],
                      "count": 2,
                      "r1": 3,
                      "x": 5,
                  },
                  {
                      "group": False,
                      "row_idx": 1,
                      "sum": 6,
                      "collect": [2, 3],
                      "count": 2,
                      "r1": 3,
                      "x": 5,
                  },
                  {
                      "group": False,
                      "row_idx": 2,
                      "sum": 7,
                      "collect": [2, 3],
                      "count": 2,
                      "r1": 3,
                      "x": 5,
                  },
                  {
                      "group": False,
                      "row_idx": 3,
                      "sum": 8,
                      "collect": [2, 3],
                      "count": 2,
                      "r1": 3,
                      "x": 5,
                  },
              ],
              hl.tstruct(
                  row_idx=hl.tint32,
                  r1=hl.tint32,
                  group=hl.tbool,
                  collect=hl.tarray(hl.tint32),
                  count=hl.tint64,
                  sum=hl.tint64,
                  x=hl.tint32,
              ),
          )
          .annotate_globals(glob=5)
          .key_by("row_idx", "group")
      )
  
      self.assertTrue(col_result.entries()._same(col_expected))
  
file_path: hail/hail/python/test/hail/matrixtable/test_grouped_matrix_table.py
imports: import unittest
  import hail
  from ..helpers import *
label_desc: Use image node_id 9 for calling the Tests obj's underlying member method code with example usage: obj.test_group_cols_by_aggregate() without return types