def pad_and_convert_to_tensor(self, tokens, token_types, masked_positions, masked_labels):
    'Pad sequences and convert them to tensor.'
    num_tokens = len(tokens)
    num_pad = (self.max_seq_length - num_tokens)
    assert (num_pad >= 0)
    assert (len(token_types) == num_tokens)
    assert (len(masked_positions) == len(masked_labels))
    filler = ([self.pad_id] * num_pad)
    tokens = flow.tensor((tokens + filler), dtype=flow.long)
    token_types = flow.tensor((token_types + filler), dtype=flow.long)
    padding_mask = flow.tensor((([1] * num_tokens) + ([0] * num_pad)), dtype=flow.long)
    labels = ([(- 1)] * self.max_seq_length)
    loss_mask = ([0] * self.max_seq_length)
    for (idx, label) in zip(masked_positions, masked_labels):
        assert (idx < num_tokens)
        labels[idx] = label
        loss_mask[idx] = 1
    labels = flow.tensor(labels, dtype=flow.long)
    loss_mask = flow.tensor(loss_mask, dtype=flow.long)
    return (tokens, token_types, labels, padding_mask, loss_mask)
Pad sequences and convert them to tensor.
def pad_and_convert_to_tensor(self, tokens, token_types, masked_positions, masked_labels):
    
    num_tokens = len(tokens)
    num_pad = (self.max_seq_length - num_tokens)
    assert (num_pad >= 0)
    assert (len(token_types) == num_tokens)
    assert (len(masked_positions) == len(masked_labels))
    filler = ([self.pad_id] * num_pad)
    tokens = flow.tensor((tokens + filler), dtype=flow.long)
    token_types = flow.tensor((token_types + filler), dtype=flow.long)
    padding_mask = flow.tensor((([1] * num_tokens) + ([0] * num_pad)), dtype=flow.long)
    labels = ([(- 1)] * self.max_seq_length)
    loss_mask = ([0] * self.max_seq_length)
    for (idx, label) in zip(masked_positions, masked_labels):
        assert (idx < num_tokens)
        labels[idx] = label
        loss_mask[idx] = 1
    labels = flow.tensor(labels, dtype=flow.long)
    loss_mask = flow.tensor(loss_mask, dtype=flow.long)
    return (tokens, token_types, labels, padding_mask, loss_mask)