def _collate(self, batch):
Y_batch = None<EOL>if isinstance(batch[<NUM_LIT:0>], tuple):<EOL><INDENT>batch, Y_batch = list(zip(*batch))<EOL>Y_batch = self._cuda(torch.Tensor(Y_batch))<EOL><DEDENT>batch, f_batch, v_batch = list(zip(*batch))<EOL>f_batch, _ = pad_batch(f_batch, <NUM_LIT:0>)<EOL>v_batch, _ = pad_batch(v_batch, <NUM_LIT:0>, type="<STR_LIT:float>")<EOL>f_batch = self._cuda(f_batch)<EOL>v_batch = self._cuda(v_batch)<EOL>X_batch = []<EOL>for samples in list(zip(*batch)):<EOL><INDENT>x, x_mask = pad_batch(samples, max_len=self.settings["<STR_LIT>"])<EOL>X_batch.append((self._cuda(x), self._cuda(x_mask)))<EOL><DEDENT>X_batch.extend([f_batch, v_batch])<EOL>if Y_batch is not None:<EOL><INDENT>return X_batch, Y_batch<EOL><DEDENT>else:<EOL><INDENT>return X_batch<EOL><DEDENT>
Puts each data field into a tensor.

:param batch: The input data batch.
:type batch: list of (word sequences, features, feature_weights) tuples
:return: Preprocessed data.
:rtype: list of torch.Tensor with torch.Tensor (Optional)