code: def cumsum(x):
      def _xla_friendly(x):
          return tf.math.cumsum(x)
  
      def _xla_hostile(x):
          return tf.while_loop(
              cond=lambda x, _: tf.size(x) > 0,
              body=lambda x, cx: (
                  x[:-1],  # pylint: disable=g-long-lambda
                  cx + tf.pad(x, [[tf.size(cx) - tf.size(x), 0]]),
              ),
              loop_vars=[x, tf.zeros_like(x)],
              shape_invariants=[tf.TensorShape([None]), x.shape],
          )[1]
  
      return implementation_selection.implementation_selecting(
          "cumsum", default_fn=_xla_friendly, cpu_fn=_xla_hostile
      )(x=x)
  
file_path: probability/tensorflow_probability/python/internal/implementation_selection_test.py
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.internal import implementation_selection
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 1 for calling a global function with example usage: cumsum(x) and returns: implementation_selection, tf, tf