code: def handle_options(func, x, axis, exclusive, reverse):
      """Adds tf options to numpy scan ops."""
      length = len(x.shape)
      if axis < 0:
          axis = length + axis
  
      if reverse:
          x = numpy_reverse(x, axis)
  
      if exclusive:
          ix_head = [
              slice(0, 1) if i == axis else slice(None)
              for i in range(length)
          ]
          ix_init = [
              slice(0, -1) if i == axis else slice(None)
              for i in range(length)
          ]
          if func == np.cumsum:
              init = np.zeros_like(x[tuple(ix_head)])
          elif func == np.cumprod:
              init = np.ones_like(x[tuple(ix_head)])
          else:
              raise ValueError("Unknown scan function.")
          x = np.concatenate(
              [init, func(x[tuple(ix_init)], axis)], axis=axis
          )
      else:
          x = func(x, axis=axis)
  
      if reverse:
          x = numpy_reverse(x, axis)
      return x
  
imports: import numpy
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import gradient_checker
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling a global function with example usage: handle_options(func, x, axis, exclusive, reverse) and returns: x