from typing import List


def get_tail_size(shape: List[int], ndims: int) -> int:
    """
    Get the total size of the tail of a given shape.

    Args:
        shape: The whole shape.
        ndims: The number of tail dimensions.
            ``ndims <= len(shape)`` is required.

    Returns:
        The total size of the tail.
    """
    rank = len(shape)
    if rank < ndims:
        raise ValueError('`ndims <= len(shape)` does not hold: '
                         '`ndims` == {}, `shape` == {}'.format(ndims, shape))
    r = 1
    for i in range(rank - ndims, rank):
        r *= shape[i]
    return r