code: def _get_generic_filter_red(
      rk,
      in_dtype,
      out_dtype,
      filter_size,
      mode,
      wshape,
      offsets,
      cval,
      int_type,
  ):
      """Generic filter implementation based on a reduction kernel."""
      # Get the temporary output c type
      in_param, out_param = rk.in_params[0], rk.out_params[0]
      out_ctype = out_param.ctype
      if out_param.dtype is None:  # resolve template
          out_ctype = cupy._core._scalar.get_typename(
              in_dtype
              if out_param.ctype == in_param.ctype
              else out_dtype
          )
  
      # Get code chunks
      setup = """
      int iv = 0;
      X values[{size}];
      CArray<X, 1, true, true> sub_in(values, {{{size}}});
      {out_ctype} val_out;
      CArray<{out_ctype}, 1, true, true> sub_out(&val_out, {{1}});
      """.format(
          size=filter_size, out_ctype=out_ctype
      )
  
      sub_call = """reduction_kernel::{}(sub_in, sub_out);
      y = cast<Y>(val_out);""".format(
          rk.name
      )
  
      sub_kernel = _reduction_kernel_code(
          rk, filter_size, out_dtype, in_dtype
      )
  
      # Get the final kernel
      return _filters_core._generate_nd_kernel(
          "generic_{}_{}".format(filter_size, rk.name),
          setup,
          "values[iv++] = {value};",
          sub_call,
          mode,
          wshape,
          int_type,
          offsets,
          cval,
          preamble=sub_kernel,
          options=getattr(rk, "options", ()),
      )
  
file_path: cupy/cupyx/scipy/ndimage/_filters_generic.py
imports: import cupy
  from cupy_backends.cuda.api import runtime
  from cupy import _util
  from cupyx.scipy.ndimage import _filters_core
label_desc: Use image node_id 2 for calling a global function with example usage: _get_generic_filter_red(rk, in_dtype, out_dtype, filter_size, mode, wshape, offsets, cval, int_type) and returns: _filters_core