cands = batch.candidates
// batch.candidate_vecs is a [batchsize] list of [num_cand] lists of
// [seq_len] LongTensors
max_len = max(len(t) for t_list in batch.candidate_vecs for t in t_list)
cand_tensor_list = [self._cat_and_pad(cand_list, max_len=max_len,
use_cuda=self.use_cuda) for cand_list in batch.candidate_vecs]
// cand_tensor_list is a [batchsize] list of [num_cand, seq_len] LongTensors
cand_vecs = torch.stack(cand_tensor_list, 0)
// cands is a [batchsize, cand_len, seq_len] LongTensor
if label_vecs is not None:
label_inds = label_vecs.new_empty(batchsize)
for i, label_vec in enumerate(label_vecs):