examples/research_projects/luke/luke_utils.py/padding_tensor
def padding_tensor(sequences, padding_value, padding_side, sequence_length):
    if isinstance(padding_value, tuple):
        out_tensor = np.full((len(sequences), sequence_length, 2), padding_value)
    else:
        out_tensor = np.full((len(sequences), sequence_length), padding_value)

    for i, tensor in enumerate(sequences):
        if padding_side == "right":
            if isinstance(padding_value, tuple):
                out_tensor[i, : len(tensor[:sequence_length]), :2] = tensor[:sequence_length]
            else:
                out_tensor[i, : len(tensor[:sequence_length])] = tensor[:sequence_length]
        else:
            if isinstance(padding_value, tuple):
                out_tensor[i, len(tensor[:sequence_length]) - 1 :, :2] = tensor[:sequence_length]
            else:
                out_tensor[i, len(tensor[:sequence_length]) - 1 :] = tensor[:sequence_length]

    return out_tensor.tolist()