code: def numba_funcify_CumOp(op: CumOp, node: Apply, **kwargs):
      axis = op.axis
      mode = op.mode
      ndim = cast(TensorVariable, node.outputs[0]).ndim
  
      if axis is not None:
          if axis < 0:
              axis = ndim + axis
          if axis < 0 or axis >= ndim:
              raise ValueError(
                  f"Invalid axis {axis} for array with ndim {ndim}"
              )
  
          reaxis_first = (axis,) + tuple(
              i for i in range(ndim) if i != axis
          )
          reaxis_first_inv = tuple(np.argsort(reaxis_first))
  
      if mode == "add":
          if axis is None or ndim == 1:
  
              @numba_basic.numba_njit(fastmath=config.numba__fastmath)
              def cumop(x):
                  return np.cumsum(x)
  
          else:
  
              @numba_basic.numba_njit(
                  boundscheck=False, fastmath=config.numba__fastmath
              )
              def cumop(x):
                  out_dtype = x.dtype
                  if x.shape[axis] < 2:
                      return x.astype(out_dtype)
  
                  x_axis_first = x.transpose(reaxis_first)
                  res = np.empty(x_axis_first.shape, dtype=out_dtype)
  
                  res[0] = x_axis_first[0]
                  for m in range(1, x.shape[axis]):
                      res[m] = res[m - 1] + x_axis_first[m]
  
                  return res.transpose(reaxis_first_inv)
  
      else:
          if axis is None or ndim == 1:
  
              @numba_basic.numba_njit(fastmath=config.numba__fastmath)
              def cumop(x):
                  return np.cumprod(x)
  
          else:
  
              @numba_basic.numba_njit(
                  boundscheck=False, fastmath=config.numba__fastmath
              )
              def cumop(x):
                  out_dtype = x.dtype
                  if x.shape[axis] < 2:
                      return x.astype(out_dtype)
  
                  x_axis_first = x.transpose(reaxis_first)
                  res = np.empty(x_axis_first.shape, dtype=out_dtype)
  
                  res[0] = x_axis_first[0]
                  for m in range(1, x.shape[axis]):
                      res[m] = res[m - 1] * x_axis_first[m]
  
                  return res.transpose(reaxis_first)
  
      return cumop
  
imports: import warnings
  from typing import cast
  import numba
  import numpy
  from pytensor import config
  from pytensor.graph import Apply
  from pytensor.link.numba.dispatch import basic
  from pytensor.link.numba.dispatch.basic import get_numba_type, numba_funcify
  from pytensor.raise_op import CheckAndRaise
  from pytensor.tensor import TensorVariable
  from pytensor.tensor.extra_ops import Bartlett, CumOp, FillDiagonal, FillDiagonalOffset, RavelMultiIndex, Repeat, SearchsortedOp, Unique, UnravelIndex
label_desc: Use image node_id 2 for calling a global function with example usage: numba_funcify_CumOp(op, node) and returns: cumop, np, res, np, res, x, x