    @staticmethod
    def _pad_sequence(sequences, pad_symbol=0):
        sequence_lengths = [len(sequence) for sequence in sequences]
        max_len = max(sequence_lengths)
        for i, length in enumerate(sequence_lengths):
            to_add = max_len - length
            sequences[i] += [pad_symbol] * to_add
        return sequences, sequence_lengths

    def collate_function(self, batch):
        src_list, src_length_list = TVAEDataset._pad_sequence(
            [example[:self.limit] for example in batch], self.pad_symbol)
        batch = {
            "src": torch.LongTensor(src_list)