def row_major_form_to_ragged_array(flat, indices):
    """Convert [1, 2, 3, 5, 6], [0, 3] to
    [[1,2,3], [5,6]] for serialization
    """
    endices = indices[1:] + [None]
    return [flat[start:end] for start, end in zip(indices, endices)]