code: def _get_row_lengths(segments, axis=-1):
      axis = array_ops.get_positive_axis(axis, segments.shape.ndims) - 1
      foo = ragged_tensor.RaggedTensor.from_nested_row_lengths(
          segments.nested_row_lengths()[axis],
          segments.nested_row_lengths()[:axis],
      )
      for _ in range(axis):
          foo = math_ops.reduce_sum(foo, -1)
      return foo
  
imports: import abc
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops.ragged import ragged_array_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow_text.python.ops import item_selector_ops
  from tensorflow.python.framework import load_library
  from tensorflow.python.platform import resource_loader
  from tensorflow.python.ops import while_loop
label_desc: Use image node_id 1 for calling a global function with example usage: _get_row_lengths(segments, axis) and returns: foo