code: def _get_min_or_max_kernel(
      mode,
      w_shape,
      func,
      offsets,
      cval,
      int_type,
      has_weights=True,
      has_structure=False,
      has_central_value=True,
  ):
      # When there are no 'weights' (the footprint, for the 1D variants) then
      # we need to make sure intermediate results are stored as doubles for
      # consistent results with scipy.
      ctype = "X" if has_weights else "double"
      value = "{value}"
      if not has_weights:
          value = "cast<double>({})".format(value)
  
      # Having a non-flat structure biases the values
      if has_structure:
          value += ("-" if func == "min" else "+") + "cast<X>(sval)"
  
      if has_central_value:
          pre = "{} value = x[i];"
          found = "value = {func}({value}, value);"
      else:
          # If the central pixel is not included in the footprint we cannot
          # assume `x[i]` is not below the min or above the max and thus cannot
          # seed with that value. Instead we keep track of having set `value`.
          pre = "{} value; bool set = false;"
          found = "value = set ? {func}({value}, value) : {value}; set=true;"
  
      return _filters_core._generate_nd_kernel(
          func,
          pre.format(ctype),
          found.format(func=func, value=value),
          "y = cast<Y>(value);",
          mode,
          w_shape,
          int_type,
          offsets,
          cval,
          ctype=ctype,
          has_weights=has_weights,
          has_structure=has_structure,
      )
  
imports: import numpy
  import cupy
  from cupy import _core
  from cupy._core import internal
  from cupyx.scipy.ndimage import _util
  from cupyx.scipy.ndimage import _filters_core
  from cupyx.scipy.ndimage import _filters_generic
label_desc: Use image node_id 27 for calling a global function with example usage: _get_min_or_max_kernel(mode, w_shape, func, offsets, cval, int_type, has_weights, has_structure, has_central_value) and returns: _filters_core