def __iter__(self, random=False):
    (batch_token_ids, batch_segment_ids, batch_labels) = ([], [], [])
    for (is_end, (text, label)) in self.sample(random):
        (token_ids, segment_ids) = tokenizer.encode(text, max_length=maxlen)
        batch_token_ids.append(token_ids)
        batch_segment_ids.append(segment_ids)
        batch_labels.append([label])
        if ((len(batch_token_ids) == self.batch_size) or is_end):
            batch_token_ids = sequence_padding(batch_token_ids)
            batch_segment_ids = sequence_padding(batch_segment_ids)
            batch_labels = sequence_padding(batch_labels)
            (yield ([batch_token_ids, batch_segment_ids], batch_labels))
            (batch_token_ids, batch_segment_ids, batch_labels) = ([], [], [])
def __iter__(self, random=False):
    (batch_token_ids, batch_segment_ids, batch_labels) = ([], [], [])
    for (is_end, (text, label)) in self.sample(random):
        (token_ids, segment_ids) = tokenizer.encode(text, max_length=maxlen)
        batch_token_ids.append(token_ids)
        batch_segment_ids.append(segment_ids)
        batch_labels.append([label])
        if ((len(batch_token_ids) == self.batch_size) or is_end):
            batch_token_ids = sequence_padding(batch_token_ids)
            batch_segment_ids = sequence_padding(batch_segment_ids)
            batch_labels = sequence_padding(batch_labels)
            (yield ([batch_token_ids, batch_segment_ids], batch_labels))
            (batch_token_ids, batch_segment_ids, batch_labels) = ([], [], [])