class_docstr: Pairwise likelihood base class for pairwise preference GP (e.g., PairwiseGP).
  
  :meta private:
docstr: Given the difference in (estimated) utility util_diff = f(v) - f(u),
  return the probability of the user prefer v over u.
  
  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.
      log: if true, return log probability
docstr_tok: ["Given","the","difference","in","(","estimated",")","utility","util_diff","=","f","(","v",")","-","f","(","u",")",",","return","the","probability","of","the","user","prefer","v","over","u.","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.","log",":","if","true",",","return","log","probability"]
code: def p(self, utility: Tensor, D: Tensor) -> Tensor:
      """Given the difference in (estimated) utility util_diff = f(v) - f(u),
      return the probability of the user prefer v over u.
  
      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.
          log: if true, return log probability
      """
  
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 3 for calling the PairwiseLikelihood obj's underlying member method code with example usage: obj.p(utility, D) without return types