def batchify_sentence_classification_with_label(input_batch_list, gpu, if_train=True):
    '\n        input: list of words, chars and labels, various length. [[words, features, chars, labels],[words, features, chars,labels],...]\n            words: word ids for one sentence. (batch_size, sent_len)\n            features: features ids for one sentence. (batch_size, feature_num), each sentence has one set of feature\n            chars: char ids for on sentences, various length. (batch_size, sent_len, each_word_length)\n            labels: label ids for one sentence. (batch_size,), each sentence has one set of feature\n\n        output:\n            zero padding for word and char, with their batch length\n            word_seq_tensor: (batch_size, max_sent_len) Variable\n            feature_seq_tensors: [(batch_size,), ... ] list of Variable\n            word_seq_lengths: (batch_size,1) Tensor\n            char_seq_tensor: (batch_size*max_sent_len, max_word_len) Variable\n            char_seq_lengths: (batch_size*max_sent_len,1) Tensor\n            char_seq_recover: (batch_size*max_sent_len,1)  recover char sequence order\n            label_seq_tensor: (batch_size, )\n            mask: (batch_size, max_sent_len)\n    '
    batch_size = len(input_batch_list)
    words = [sent[0] for sent in input_batch_list]
    features = [np.asarray(sent[1]) for sent in input_batch_list]
    feature_num = len(features[0])
    chars = [sent[2] for sent in input_batch_list]
    labels = [sent[3] for sent in input_batch_list]
    word_seq_lengths = torch.LongTensor(list(map(len, words)))
    max_seq_len = word_seq_lengths.max().item()
    word_seq_tensor = torch.zeros((batch_size, max_seq_len), requires_grad=if_train).long()
    label_seq_tensor = torch.zeros((batch_size,), requires_grad=if_train).long()
    feature_seq_tensors = []
    for idx in range(feature_num):
        feature_seq_tensors.append(torch.zeros((batch_size, max_seq_len), requires_grad=if_train).long())
    ' 517 '
    mask = torch.zeros((batch_size, max_seq_len), requires_grad=if_train).bool()
    label_seq_tensor = torch.LongTensor(labels)
    for (idx, (seq, seqlen)) in enumerate(zip(words, word_seq_lengths)):
        seqlen = seqlen.item()
        word_seq_tensor[idx, :seqlen] = torch.LongTensor(seq)
        mask[idx, :seqlen] = torch.Tensor(([1] * seqlen))
        for idy in range(feature_num):
            feature_seq_tensors[idy][idx, :seqlen] = torch.LongTensor(features[idx][:, idy])
    (word_seq_lengths, word_perm_idx) = word_seq_lengths.sort(0, descending=True)
    word_seq_tensor = word_seq_tensor[word_perm_idx]
    for idx in range(feature_num):
        feature_seq_tensors[idx] = feature_seq_tensors[idx][word_perm_idx]
    label_seq_tensor = label_seq_tensor[word_perm_idx]
    mask = mask[word_perm_idx]
    pad_chars = [(chars[idx] + ([[0]] * (max_seq_len - len(chars[idx])))) for idx in range(len(chars))]
    length_list = [list(map(len, pad_char)) for pad_char in pad_chars]
    max_word_len = max(map(max, length_list))
    char_seq_tensor = torch.zeros((batch_size, max_seq_len, max_word_len), requires_grad=if_train).long()
    char_seq_lengths = torch.LongTensor(length_list)
    for (idx, (seq, seqlen)) in enumerate(zip(pad_chars, char_seq_lengths)):
        for (idy, (word, wordlen)) in enumerate(zip(seq, seqlen)):
            char_seq_tensor[idx, idy, :wordlen] = torch.LongTensor(word)
    char_seq_tensor = char_seq_tensor[word_perm_idx].view((batch_size * max_seq_len), (- 1))
    char_seq_lengths = char_seq_lengths[word_perm_idx].view((batch_size * max_seq_len))
    (char_seq_lengths, char_perm_idx) = char_seq_lengths.sort(0, descending=True)
    char_seq_tensor = char_seq_tensor[char_perm_idx]
    (_, char_seq_recover) = char_perm_idx.sort(0, descending=False)
    (_, word_seq_recover) = word_perm_idx.sort(0, descending=False)
    if gpu:
        word_seq_tensor = word_seq_tensor.cuda()
        for idx in range(feature_num):
            feature_seq_tensors[idx] = feature_seq_tensors[idx].cuda()
        word_seq_lengths = word_seq_lengths.cuda()
        word_seq_recover = word_seq_recover.cuda()
        label_seq_tensor = label_seq_tensor.cuda()
        char_seq_tensor = char_seq_tensor.cuda()
        char_seq_recover = char_seq_recover.cuda()
        mask = mask.cuda()
    return (word_seq_tensor, feature_seq_tensors, word_seq_lengths, word_seq_recover, char_seq_tensor, char_seq_lengths, char_seq_recover, label_seq_tensor, mask)
input: list of words, chars and labels, various length. [[words, features, chars, labels],[words, features, chars,labels],...]
    words: word ids for one sentence. (batch_size, sent_len)
    features: features ids for one sentence. (batch_size, feature_num), each sentence has one set of feature
    chars: char ids for on sentences, various length. (batch_size, sent_len, each_word_length)
    labels: label ids for one sentence. (batch_size,), each sentence has one set of feature

output:
    zero padding for word and char, with their batch length
    word_seq_tensor: (batch_size, max_sent_len) Variable
    feature_seq_tensors: [(batch_size,), ... ] list of Variable
    word_seq_lengths: (batch_size,1) Tensor
    char_seq_tensor: (batch_size*max_sent_len, max_word_len) Variable
    char_seq_lengths: (batch_size*max_sent_len,1) Tensor
    char_seq_recover: (batch_size*max_sent_len,1)  recover char sequence order
    label_seq_tensor: (batch_size, )
    mask: (batch_size, max_sent_len)
def batchify_sentence_classification_with_label(input_batch_list, gpu, if_train=True):
    '\n        input: list of words, chars and labels, various length. [[words, features, chars, labels],[words, features, chars,labels],...]\n            words: word ids for one sentence. (batch_size, sent_len)\n            features: features ids for one sentence. (batch_size, feature_num), each sentence has one set of feature\n            chars: char ids for on sentences, various length. (batch_size, sent_len, each_word_length)\n            labels: label ids for one sentence. (batch_size,), each sentence has one set of feature\n\n        output:\n            zero padding for word and char, with their batch length\n            word_seq_tensor: (batch_size, max_sent_len) Variable\n            feature_seq_tensors: [(batch_size,), ... ] list of Variable\n            word_seq_lengths: (batch_size,1) Tensor\n            char_seq_tensor: (batch_size*max_sent_len, max_word_len) Variable\n            char_seq_lengths: (batch_size*max_sent_len,1) Tensor\n            char_seq_recover: (batch_size*max_sent_len,1)  recover char sequence order\n            label_seq_tensor: (batch_size, )\n            mask: (batch_size, max_sent_len)\n    '
    batch_size = len(input_batch_list)
    words = [sent[0] for sent in input_batch_list]
    features = [np.asarray(sent[1]) for sent in input_batch_list]
    feature_num = len(features[0])
    chars = [sent[2] for sent in input_batch_list]
    labels = [sent[3] for sent in input_batch_list]
    word_seq_lengths = torch.LongTensor(list(map(len, words)))
    max_seq_len = word_seq_lengths.max().item()
    word_seq_tensor = torch.zeros((batch_size, max_seq_len), requires_grad=if_train).long()
    label_seq_tensor = torch.zeros((batch_size,), requires_grad=if_train).long()
    feature_seq_tensors = []
    for idx in range(feature_num):
        feature_seq_tensors.append(torch.zeros((batch_size, max_seq_len), requires_grad=if_train).long())
    ' 517 '
    mask = torch.zeros((batch_size, max_seq_len), requires_grad=if_train).bool()
    label_seq_tensor = torch.LongTensor(labels)
    for (idx, (seq, seqlen)) in enumerate(zip(words, word_seq_lengths)):
        seqlen = seqlen.item()
        word_seq_tensor[idx, :seqlen] = torch.LongTensor(seq)
        mask[idx, :seqlen] = torch.Tensor(([1] * seqlen))
        for idy in range(feature_num):
            feature_seq_tensors[idy][idx, :seqlen] = torch.LongTensor(features[idx][:, idy])
    (word_seq_lengths, word_perm_idx) = word_seq_lengths.sort(0, descending=True)
    word_seq_tensor = word_seq_tensor[word_perm_idx]
    for idx in range(feature_num):
        feature_seq_tensors[idx] = feature_seq_tensors[idx][word_perm_idx]
    label_seq_tensor = label_seq_tensor[word_perm_idx]
    mask = mask[word_perm_idx]
    pad_chars = [(chars[idx] + ([[0]] * (max_seq_len - len(chars[idx])))) for idx in range(len(chars))]
    length_list = [list(map(len, pad_char)) for pad_char in pad_chars]
    max_word_len = max(map(max, length_list))
    char_seq_tensor = torch.zeros((batch_size, max_seq_len, max_word_len), requires_grad=if_train).long()
    char_seq_lengths = torch.LongTensor(length_list)
    for (idx, (seq, seqlen)) in enumerate(zip(pad_chars, char_seq_lengths)):
        for (idy, (word, wordlen)) in enumerate(zip(seq, seqlen)):
            char_seq_tensor[idx, idy, :wordlen] = torch.LongTensor(word)
    char_seq_tensor = char_seq_tensor[word_perm_idx].view((batch_size * max_seq_len), (- 1))
    char_seq_lengths = char_seq_lengths[word_perm_idx].view((batch_size * max_seq_len))
    (char_seq_lengths, char_perm_idx) = char_seq_lengths.sort(0, descending=True)
    char_seq_tensor = char_seq_tensor[char_perm_idx]
    (_, char_seq_recover) = char_perm_idx.sort(0, descending=False)
    (_, word_seq_recover) = word_perm_idx.sort(0, descending=False)
    if gpu:
        word_seq_tensor = word_seq_tensor.cuda()
        for idx in range(feature_num):
            feature_seq_tensors[idx] = feature_seq_tensors[idx].cuda()
        word_seq_lengths = word_seq_lengths.cuda()
        word_seq_recover = word_seq_recover.cuda()
        label_seq_tensor = label_seq_tensor.cuda()
        char_seq_tensor = char_seq_tensor.cuda()
        char_seq_recover = char_seq_recover.cuda()
        mask = mask.cuda()
    return (word_seq_tensor, feature_seq_tensors, word_seq_lengths, word_seq_recover, char_seq_tensor, char_seq_lengths, char_seq_recover, label_seq_tensor, mask)