def input_pad_to_len(words, padded_word_len, padded_char_len, word_padding=0, char_padding=0):
    """Pad words to 'padded_word_len' with padding if 'len(words) < padded_word_len'. Then add padding so that each word has the same length 'padded_char_len'.
    Example:
        input_pad_to_len([[1, 2, 3],
                          [2, 3],
                          [3]], 5, -1, 0)
                          
        ==============>  [[1, 2, 3],
                          [2, 3, 0],
                          [3, 0, 0],
                          [-1, 0, 0],
                          [-1, 0, 0]]
    Args:
        words (list): List of list of the word index.
        padded_word_len (int): The length for padding a batch of sequences to the same length.
        padded_char_len (int): The length for padding each word in the sentences to the same length.
        word_padding (int): The index used to pad the input sequence.
        char_padding (int): The index used to pad each word in the input sequence.
    """
    if len(words) < padded_word_len:
        words += [[word_padding]] * (padded_word_len - len(words))
    words = [word + [char_padding] * (padded_char_len - len(word)) if len(word) < padded_char_len else word for word in words]
    return words