from typing import List
from typing import Any


def pad(sents: List[List[Any]], pad_token: Any):
    """ Pad list of sentences according to the longest sentence in the batch.
    @param sents: list of sentences, where each sentence
                                    is represented as a list of words
    @param pad_token: padding token
    @returns sents_padded: list of sentences where sentences shorter
        than the max length sentence are padded out with the pad_token, such that
        each sentences in the batch now has equal length.
    """
    sents_padded = []
    sents_len = list(map(lambda x: len(x), sents))
    max_len = max(sents_len)
    for sent_len, sent in zip(list(sents_len), sents):
        sents_padded.append(sent + [pad_token] * (max_len - sent_len))

    return sents_padded