def _size_from_shape(shape: tuple) -> int:
    """
    From a tuple reprensenting a shape of a vector it retrives the size.

    For example (5, 1, 8) --> 40

    :param shape: the shape
    :return: the corresponding size
    """
    if not shape:
        return 0

    out = 1
    for k in shape:
        out *= k
    return out