code: def _get_row_lengths_merged_to_axis(segments, axis=-1):
      """Get the row lengths relative to a desired axis."""
      axis = array_ops.get_positive_axis(axis, segments.shape.ndims) - 1
      row_lengths = ragged_tensor.RaggedTensor.from_nested_row_lengths(
          segments.nested_row_lengths()[axis],
          segments.nested_row_lengths()[:axis],
      )
      for _ in range(axis):
          row_lengths = math_ops.reduce_sum(row_lengths, -1)
      return row_lengths
  
imports: 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 gen_array_ops
  from tensorflow.python.ops import map_fn
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops.ragged import ragged_array_ops
  from tensorflow.python.ops.ragged import ragged_functional_ops
  from tensorflow.python.ops.ragged import ragged_math_ops
  from tensorflow.python.ops.ragged import ragged_tensor
label_desc: Use image node_id 1 for calling a global function with example usage: _get_row_lengths_merged_to_axis(segments, axis) and returns: row_lengths