code: def combine_r(ts, ref_block_max_len_field):
      ts = Table(
          TableMapRows(
              ts._tir, combine_reference_row(ts.row, ts.globals)._ir
          )
      )
  
      global_fds = {"__cols": hl.flatten(ts.g.map(lambda g: g.__cols))}
      if ref_block_max_len_field is not None:
          global_fds[ref_block_max_len_field] = hl.max(
              ts.g.map(lambda g: g[ref_block_max_len_field])
          )
      return ts.transmute_globals(**global_fds)
  
imports: import math
  from typing import Collection, Optional, Set, Union, List, Tuple, Dict
  import hail
  from hail import MatrixTable, Table
  from hail.experimental.function import Function
  from hail.expr import StructExpression, unify_all, construct_expr
  from hail.expr.expressions import expr_bool, expr_str
  from hail.genetics.reference_genome import reference_genome_type
  from hail.ir import Apply, TableMapRows
  from hail.typecheck import oneof, sequenceof, typecheck
  from ..variant_dataset import VariantDataset
label_desc: Use image node_id 7 for calling a global function with example usage: combine_r(ts, ref_block_max_len_field) and returns: ts