def marginals(self, X):
nn.Module.train(self, False)<EOL>if self._check_input(X):<EOL><INDENT>X = self._preprocess_data(X)<EOL><DEDENT>dataloader = DataLoader(<EOL>MultiModalDataset(X),<EOL>batch_size=self.settings["<STR_LIT>"],<EOL>collate_fn=self._collate_fn(),<EOL>shuffle=False,<EOL>)<EOL>marginals = torch.Tensor([])<EOL>for X_batch in dataloader:<EOL><INDENT>marginal = self._non_cuda(self._calc_logits(X_batch))<EOL>marginals = torch.cat((marginals, marginal), <NUM_LIT:0>)<EOL><DEDENT>return F.softmax(marginals, dim=-<NUM_LIT:1>).detach().numpy()<EOL>
Compute the marginals for the given candidates X.
Note: split into batches to avoid OOM errors.

:param X: The input data which is a (list of Candidate objects, a sparse
    matrix of corresponding features) pair or a list of
    (Candidate, features) pairs.
:type X: pair or list