def __getitem__(self, idx):
    np_rng = np.random.RandomState(seed=(self.seed + idx))
    sents = self.dataset[idx]
    if self.binary_head:
        (tokens_a, tokens_b, is_next_random) = self.create_random_sentence_pair(sents, np_rng)
    else:
        tokens_a = []
        for j in range(len(sents)):
            tokens_a.extend(sents[j])
        tokens_b = []
        is_next_random = False
    (tokens_a, tokens_b) = self.truncate_seq_pair(tokens_a, tokens_b, (self.max_seq_length - 3), np_rng)
    (tokens, token_types) = self.create_tokens_and_token_types(tokens_a, tokens_b)
    (tokens, masked_positions, masked_labels) = self.create_masked_lm_predictions(tokens, np_rng)
    (tokens, token_types, labels, padding_mask, loss_mask) = self.pad_and_convert_to_tensor(tokens, token_types, masked_positions, masked_labels)
    sample = Instance(input_ids=DistTensorData(tokens), attention_mask=DistTensorData(padding_mask), tokentype_ids=DistTensorData(token_types), ns_labels=DistTensorData(flow.tensor(int(is_next_random), dtype=flow.long), placement_idx=(- 1)), lm_labels=DistTensorData(labels, placement_idx=(- 1)), loss_mask=DistTensorData(loss_mask, placement_idx=(- 1)))
    return sample
def __getitem__(self, idx):
    np_rng = np.random.RandomState(seed=(self.seed + idx))
    sents = self.dataset[idx]
    if self.binary_head:
        (tokens_a, tokens_b, is_next_random) = self.create_random_sentence_pair(sents, np_rng)
    else:
        tokens_a = []
        for j in range(len(sents)):
            tokens_a.extend(sents[j])
        tokens_b = []
        is_next_random = False
    (tokens_a, tokens_b) = self.truncate_seq_pair(tokens_a, tokens_b, (self.max_seq_length - 3), np_rng)
    (tokens, token_types) = self.create_tokens_and_token_types(tokens_a, tokens_b)
    (tokens, masked_positions, masked_labels) = self.create_masked_lm_predictions(tokens, np_rng)
    (tokens, token_types, labels, padding_mask, loss_mask) = self.pad_and_convert_to_tensor(tokens, token_types, masked_positions, masked_labels)
    sample = Instance(input_ids=DistTensorData(tokens), attention_mask=DistTensorData(padding_mask), tokentype_ids=DistTensorData(token_types), ns_labels=DistTensorData(flow.tensor(int(is_next_random), dtype=flow.long), placement_idx=(- 1)), lm_labels=DistTensorData(labels, placement_idx=(- 1)), loss_mask=DistTensorData(loss_mask, placement_idx=(- 1)))
    return sample