def fit_to_block_size(sequence, block_size, pad_token_id):
    """ Adapt the source and target sequences' lengths to the block size.
    If the sequence is shorter we append padding token to the right of the sequence.

    Args:
        sequence (list): sequence to be truncated to padded
        block_size (int): length of the output

    Returns:
        sequence (list): padded or shortend list

    """
    if len(sequence) > block_size:
        return sequence[:block_size]
    else:
        sequence.extend([pad_token_id] * (block_size - len(sequence)))
        return sequence
 Adapt the source and target sequences' lengths to the block size.
    If the sequence is shorter we append padding token to the right of the sequence.

    Args:
        sequence (list): sequence to be truncated to padded
        block_size (int): length of the output

    Returns:
        sequence (list): padded or shortend list

    
utils_nlp/models/transformers/abstractive_summarization_bertsum.py