from typing import Sequence
from typing import List


def tv_groupby_subst(tv: Sequence, sub_info: Sequence[int]) -> \
        List[Sequence]:
    """
    Group a sequence the shape of the topology vector by the substations.

    Parameters
    ----------
    tv : Sequence
        Sequence the shape of the topology vector.
    sub_info : Sequence[int]
        Sequence with elements containing the number of object connected to
        each substation.

    Returns
    -------
    List[Sequence]
        List, each element corresponding to a Sequence of objects in tv that
        belong to a particular substation.
    """
    i = 0
    gs = []
    for ss in sub_info:
        gs.append(tv[i:i+ss])
        i += ss
    return gs