code: def combine_variant_rows(row, globals):
      def renumber_entry(entry, old_to_new) -> StructExpression:
          # global index of alternate (non-ref) alleles
          return entry.annotate(
              LA=entry.LA.map(lambda lak: old_to_new[lak])
          )
  
      merge_function = _merge_function_map.get(
          (row.dtype, globals.dtype)
      )
      if (
          merge_function is None
          or not hl.current_backend()._is_registered_ir_function_name(
              merge_function._name
          )
      ):
          merge_function = hl.experimental.define_function(
              lambda row, gbl: hl.rbind(
                  merge_alleles(row.data.map(lambda d: d.alleles)),
                  lambda alleles: hl.struct(
                      locus=row.locus,
                      alleles=alleles.globl,
                      **(
                          {
                              "rsid": hl.find(
                                  hl.is_defined,
                                  row.data.map(lambda d: d.rsid),
                              )
                          }
                          if "rsid" in row.data.dtype.element_type
                          else {}
                      ),
                      __entries=hl.bind(
                          lambda combined_allele_index: hl.range(
                              0, hl.len(row.data)
                          ).flatmap(
                              lambda i: hl.if_else(
                                  hl.is_missing(row.data[i].__entries),
                                  hl.range(
                                      0, hl.len(gbl.g[i].__cols)
                                  ).map(
                                      lambda _: hl.missing(
                                          row.data[
                                              i
                                          ].__entries.dtype.element_type
                                      )
                                  ),
                                  hl.bind(
                                      lambda old_to_new: row.data[
                                          i
                                      ].__entries.map(
                                          lambda e: renumber_entry(
                                              e, old_to_new
                                          )
                                      ),
                                      hl.range(
                                          0, hl.len(alleles.local[i])
                                      ).map(
                                          lambda j: combined_allele_index[
                                              alleles.local[i][j]
                                          ]
                                      ),
                                  ),
                              )
                          ),
                          hl.dict(
                              hl.range(0, hl.len(alleles.globl)).map(
                                  lambda j: hl.tuple(
                                      [alleles.globl[j], j]
                                  )
                              )
                          ),
                      ),
                  ),
              ),
              row.dtype,
              globals.dtype,
          )
          _merge_function_map[
              (row.dtype, globals.dtype)
          ] = merge_function
      indices, aggs = unify_all(row, globals)
      apply_ir = Apply(
          merge_function._name,
          merge_function._ret_type,
          row._ir,
          globals._ir,
      )
      return construct_expr(apply_ir, apply_ir.typ, indices, aggs)
  
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 19 for calling a global function with example usage: combine_variant_rows(row, globals) and returns: construct_expr, entry