def padding_to_maxlength(ids, max_length, pad_id): cur_len = len(ids) len_diff = max_length - len(ids) return ids + [pad_id] * len_diff, [1] * cur_len + [0] * len_diff