(batch)
return all_input_ids, all_attention_mask, all_token_type_ids, all_labels
batch should be a list of (sequence, target, length) tuples...
    Returns a padded tensor of sequences sorted from longest to shortest,
batch should be a list of (sequence, target, length) tuples...
    Returns a padded tensor of sequences sorted from longest to shortest,
batch should be a list of ( sequence target length ) tuples ... Returns a padded tensor of sequences sorted from longest to shortest
def xlnet_collate_fn(batch):
    """
    batch should be a list of (sequence, target, length) tuples...
    Returns a padded tensor of sequences sorted from longest to shortest,
    """
    all_input_ids, all_attention_mask, all_token_type_ids, all_lens, all_labels = map(torch.stack, zip(*batch))
    max_len = max(all_lens).item()
    all_input_ids = all_input_ids[:, -max_len:]
    all_attention_mask = all_attention_mask[:, -max_len:]
    all_token_type_ids = all_token_type_ids[:, -max_len:]
    return all_input_ids, all_attention_mask, all_token_type_ids, all_labels
def xlnet_collate_fn ( batch ) : all_input_ids , all_attention_mask , all_token_type_ids , all_lens , all_labels = map ( torch . stack , zip ( * batch ) ) max_len = max ( all_lens ) . item ( ) all_input_ids = all_input_ids [ : , - max_len : ] all_attention_mask = all_attention_mask [ : , - max_len : ] all_token_type_ids = all_token_type_ids [ : , - max_len : ] return all_input_ids , all_attention_mask , all_token_type_ids , all_labels