code: def _get_antialias_stage_2_combine_func(
      combination: AntialiasCombination,
      zero: float,
      n_reduction: bool,
      categorical: bool,
  ):
      if n_reduction:
          if zero == -1:
              if combination in (
                  AntialiasCombination.MAX,
                  AntialiasCombination.LAST,
              ):
                  return (
                      row_max_n_in_place_4d
                      if categorical
                      else row_max_n_in_place_3d
                  )
              elif combination in (
                  AntialiasCombination.MIN,
                  AntialiasCombination.FIRST,
              ):
                  return (
                      row_min_n_in_place_4d
                      if categorical
                      else row_min_n_in_place_3d
                  )
              else:
                  raise NotImplementedError
          else:
              if combination == AntialiasCombination.MAX:
                  return (
                      nanmax_n_in_place_4d
                      if categorical
                      else nanmax_n_in_place_3d
                  )
              elif combination == AntialiasCombination.MIN:
                  return (
                      nanmin_n_in_place_4d
                      if categorical
                      else nanmin_n_in_place_3d
                  )
              elif combination == AntialiasCombination.FIRST:
                  return (
                      nanfirst_n_in_place_4d
                      if categorical
                      else nanfirst_n_in_place_3d
                  )
              elif combination == AntialiasCombination.LAST:
                  return (
                      nanlast_n_in_place_4d
                      if categorical
                      else nanlast_n_in_place_3d
                  )
              else:
                  raise NotImplementedError
      else:
          # The aggs to combine here are either 3D (ny, nx, ncat) if categorical is True or
          # 2D (ny, nx) if categorical is False. The same combination functions can be for both
          # as all elements are independent.
          if zero == -1:
              if combination in (
                  AntialiasCombination.MAX,
                  AntialiasCombination.LAST,
              ):
                  return row_max_in_place
              elif combination in (
                  AntialiasCombination.MIN,
                  AntialiasCombination.FIRST,
              ):
                  return row_min_in_place
              else:
                  raise NotImplementedError
          else:
              if combination == AntialiasCombination.MAX:
                  return nanmax_in_place
              elif combination == AntialiasCombination.MIN:
                  return nanmin_in_place
              elif combination == AntialiasCombination.FIRST:
                  return nanfirst_in_place
              elif combination == AntialiasCombination.LAST:
                  return nanlast_in_place
              else:
                  return nansum_in_place
  
imports: from __future__ import annotations
  from itertools import count
  import logging
  from typing import TYPE_CHECKING
  from toolz import unique, concat, pluck, get, memoize
  from numba import literal_unroll
  import numpy
  import xarray
  from .antialias import AntialiasCombination
  from .reductions import SpecialColumn, UsesCudaMutex, by, category_codes, summary
  from .utils import isnull, ngjit, nanmax_in_place, nanmin_in_place, nansum_in_place, nanfirst_in_place, nanlast_in_place, nanmax_n_in_place_3d, nanmax_n_in_place_4d, nanmin_n_in_place_3d, nanmin_n_in_place_4d, nanfirst_n_in_place_3d, nanfirst_n_in_place_4d, nanlast_n_in_place_3d, nanlast_n_in_place_4d, row_min_in_place, row_min_n_in_place_3d, row_min_n_in_place_4d, row_max_in_place, row_max_n_in_place_3d, row_max_n_in_place_4d
label_desc: Use image node_id 2 for calling a global function with example usage: _get_antialias_stage_2_combine_func(combination, zero, n_reduction, categorical) and returns: unknown, unknown, row_max_in_place, nanmax_in_place, unknown, unknown, row_min_in_place, nanmin_in_place, unknown, nanfirst_in_place, unknown, nanlast_in_place, nansum_in_place