code: def _cumop(
      op,
      x,
      axis=0,
      exclusive=False,
      reverse=False,
      name=None,
      initial_value=None,
  ):
      """Shared impl of cumsum/cumprod."""
      del name
      axis = int(axis)
      result = op(_reverse(x, axis) if reverse else x, axis)
      if reverse:
          result = _reverse(result, axis)
      if exclusive:
          paddings = [[0, 0]] * result.ndim
          if isinstance(axis, int):
              axis = (axis,)
          for ax in axis:
              paddings[ax] = [0, 1] if reverse else [1, 0]
          result = np.pad(
              result,
              paddings,
              mode="constant",
              constant_values=initial_value,
          )
          slices = [slice(None)] * result.ndim
          for ax in axis:
              slices[ax] = (
                  slice(1, None) if reverse else slice(None, -1)
              )
          result = result[tuple(slices)]
      return result
  
imports: import collections
  import functools
  import numpy
  import numpy
  from tensorflow_probability.python.internal.backend.numpy import _utils
  from tensorflow_probability.python.internal.backend.numpy.numpy_array import _reverse
  from tensorflow_probability.python.internal.backend.numpy.numpy_array import one_hot
  from tensorflow_probability.python.internal.backend.numpy.ops import _convert_to_tensor
label_desc: Use image node_id 5 for calling a global function with example usage: _cumop(op, x, axis, exclusive, reverse, name, initial_value) and returns: result