from typing import List
import torch


def pad_sequences_from_list(array: List[List[int]]) -> torch.Tensor:
    """Performs post padding on sequences to make sequences same length.
    Adds padding with id 0

    Args:
        array (List[List[int]]): List of list of token_ids

    Returns:
        torch.Tensor: Padded tensor of token ids
    """
    tensor_list = [torch.tensor(row) for row in array]
    padded_sequences = torch.nn.utils.rnn.pad_sequence(
        tensor_list, batch_first=True
    ).int()

    return padded_sequences