code: def handle_options(func, init_fn, 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 = tuple(
              slice(0, 1) if i == axis else slice(None)
              for i in range(length)
          )
          ix_init = tuple(
              slice(0, -1) if i == axis else slice(None)
              for i in range(length)
          )
          init = init_fn(x[ix_head])
          x = np.concatenate(
              [init, func(x[ix_init], axis=axis)], axis=axis
          )
      else:
          x = func(x, axis=axis)
  
      if reverse:
          x = numpy_reverse(x, axis)
      return x
  
imports: import numpy
  from tensorflow.compiler.tests import xla_test
  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 array_ops
  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, init_fn, x, axis, exclusive, reverse) and returns: x