class_docstr: Pairwise likelihood base class for pairwise preference GP (e.g., PairwiseGP).
  
  :meta private:
docstr: Calculate the sum of negative log gradient with respect to each item's latent
      utility values. Useful for models using laplace approximation.
  
  Args:
      utility: A Tensor of shape `(batch_size x) n`, the utility at MAP point
      D: D is `(batch_size x) m x n` matrix with all elements being zero in last
          dimension except at two positions D[..., i] = 1 and D[..., j] = -1
          respectively, representing item i is preferred over item j.
  
  Returns:
      A `(batch_size x) n` Tensor representing the sum of negative log gradient
      values of the likelihood over all comparisons (i.e., the m dimension)
      with respect to each item.
docstr_tok: ["Calculate","the","sum","of","negative","log","gradient","with","respect","to","each","item","'s","latent","utility","values",".","Useful","for","models","using","laplace","approximation",".","Args",":","utility",":","A","Tensor","of","shape","`","(","batch_size","x",")","n","`",",","the","utility","at","MAP","point","D",":","D","is","`","(","batch_size","x",")","m","x","n","`","matrix","with","all","elements","being","zero","in","last","dimension","except","at","two","positions","D","[","...",",","i","]","=","1","and","D","[","...",",","j","]","=","-1","respectively",",","representing","item","i","is","preferred","over","item","j",".","Returns",":","A","`","(","batch_size","x",")","n","`","Tensor","representing","the","sum","of","negative","log","gradient","values","of","the","likelihood","over","all","comparisons","(","i.e.",",","the","m","dimension",")","with","respect","to","each","item","."]
code: def negative_log_gradient_sum(
      self, utility: Tensor, D: Tensor
  ) -> Tensor:
      """Calculate the sum of negative log gradient with respect to each item's latent
          utility values. Useful for models using laplace approximation.
  
      Args:
          utility: A Tensor of shape `(batch_size x) n`, the utility at MAP point
          D: D is `(batch_size x) m x n` matrix with all elements being zero in last
              dimension except at two positions D[..., i] = 1 and D[..., j] = -1
              respectively, representing item i is preferred over item j.
  
      Returns:
          A `(batch_size x) n` Tensor representing the sum of negative log gradient
          values of the likelihood over all comparisons (i.e., the m dimension)
          with respect to each item.
      """
      raise NotImplementedError
  
imports: from __future__ import annotations
  import math
  from abc import ABC, abstractmethod
  from typing import Any, Tuple
  import torch
  from botorch.utils.probability.utils import log_ndtr, log_phi, standard_normal_log_hazard
  from gpytorch.likelihoods import Likelihood
  from torch import Tensor
  from torch.distributions import Bernoulli
label_desc: Use image node_id 5 for calling the PairwiseLikelihood obj's underlying member method code with example usage: obj.negative_log_gradient_sum(utility, D) without return types