def split(v, lengths):
    """Split an array along first dimension into slices of specified lengths."""
    i = 0
    parts = []
    for j in lengths:
        parts.append(v[i : i + j])
        i += j
    if i < len(v):
        parts.append(v[i:])
    return parts