(batch, mode)
return text
Collects a batch of text, should be list of list of int token 
       e.g. [txt1 <list>,txt2 <list>,...]
Collects a batch of text, should be list of list of int token 
       e.g. [txt1 <list>,txt2 <list>,...]
Collects a batch of text should be list of list of int token e . g . [ txt1 <list > txt2 <list > ... ]
def collect_text_batch(batch, mode):
    '''Collects a batch of text, should be list of list of int token 
       e.g. [txt1 <list>,txt2 <list>,...] '''

    # Bucketed batch should be [[txt1, txt2,...]]
    if type(batch[0][0]) is list:
        batch = batch[0]
    # Half batch size if input to long
    if len(batch[0]) > HALF_BATCHSIZE_TEXT_LEN and mode == 'train':
        batch = batch[:len(batch)//2]
    # Read batch
    text = [torch.LongTensor(b) for b in batch]
    # Zero-padding
    text = pad_sequence(text, batch_first=True)

    return text
def collect_text_batch ( batch , mode ) : # Bucketed batch should be [[txt1, txt2,...]] if type ( batch [ 0 ] [ 0 ] ) is list : batch = batch [ 0 ] # Half batch size if input to long if len ( batch [ 0 ] ) > HALF_BATCHSIZE_TEXT_LEN and mode == 'train' : batch = batch [ : len ( batch ) // 2 ] # Read batch text = [ torch . LongTensor ( b ) for b in batch ] # Zero-padding text = pad_sequence ( text , batch_first = True ) return text