code: def marginals(self, X):
          
  
          nn.Module.train(self, False)
  
          if self._check_input(X):
              X = self._preprocess_data(X)
  
          dataloader = DataLoader(
              MultiModalDataset(X),
              batch_size=self.settings["batch_size"],
              collate_fn=self._collate_fn(),
              shuffle=False,
          )
  
          marginals = torch.Tensor([])
  
          for X_batch in dataloader:
              marginal = self._non_cuda(self._calc_logits(X_batch))
              marginals = torch.cat((marginals, marginal), 0)
  
          return F.softmax(marginals, dim=-1).detach().numpy()
docs: 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