class_docstr: Variance of difference for Active Learning
  
  Given a model and an objective, calculate the posterior sample variance
  of the objective on the difference of pairs of points. See more implementation
  details in `forward`. This acquisition function is typically used with a
  pairwise model (e.g., PairwiseGP) and a likelihood/link function
  on the pair difference (e.g., logistic or probit) for pure exploration
class_docstr_tok: ["Variance","of","difference","for","Active","Learning","Given","a","model","and","an","objective",",","calculate","the","posterior","sample","variance","of","the","objective","on","the","difference","of","pairs","of","points",".","See","more","implementation","details","in","`","forward","`",".","This","acquisition","function","is","typically","used","with","a","pairwise","model","(","e.g.",",","PairwiseGP",")","and","a","likelihood\/link","function","on","the","pair","difference","(","e.g.",",","logistic","or","probit",")","for","pure","exploration"]
docstr: Evaluate PairwiseMCPosteriorVariance on the candidate set `X`.
  
  Args:
      X: A `batch_size x q x d`-dim Tensor. q should be a multiple of 2.
  
  Returns:
      Tensor of shape `batch_size x q` representing the posterior variance
      of link function at X that active learning hopes to maximize
docstr_tok: ["Evaluate","PairwiseMCPosteriorVariance","on","the","candidate","set","`","X","`",".","Args",":","X",":","A","`","batch_size","x","q","x","d","`","-dim","Tensor",".","q","should","be","a","multiple","of","2",".","Returns",":","Tensor","of","shape","`","batch_size","x","q","`","representing","the","posterior","variance","of","link","function","at","X","that","active","learning","hopes","to","maximize"]
code: def forward(self, X: Tensor) -> Tensor:
      r"""Evaluate PairwiseMCPosteriorVariance on the candidate set `X`.
  
      Args:
          X: A `batch_size x q x d`-dim Tensor. q should be a multiple of 2.
  
      Returns:
          Tensor of shape `batch_size x q` representing the posterior variance
          of link function at X that active learning hopes to maximize
      """
      if X.shape[-2] == 0 or X.shape[-2] % 2 != 0:
          raise RuntimeError(
              "q must be a multiple of 2 for PairwiseMCPosteriorVariance"
          )
  
      # The output is of shape batch_shape x 2 x d
      # For PairwiseGP, d = 1
      post = self.model.posterior(X)
      samples = self.get_posterior_samples(
          post
      )  # num_samples x batch_shape x 2 x d
  
      # The output is of shape num_samples x batch_shape x q/2 x d
      # assuming the comparison is made between the 2 * i and 2 * i + 1 elements
      samples_diff = samples[..., ::2, :] - samples[..., 1::2, :]
      mc_var = self.objective(samples_diff).var(dim=0)
      mean_mc_var = mc_var.mean(dim=-1)
  
      return mean_mc_var
  
file_path: botorch/botorch/acquisition/active_learning.py
imports: from __future__ import annotations
  from typing import Optional
  import torch
  from botorch import settings
  from botorch.acquisition.analytic import AnalyticAcquisitionFunction
  from botorch.acquisition.monte_carlo import MCAcquisitionFunction
  from botorch.acquisition.objective import MCAcquisitionObjective, PosteriorTransform
  from botorch.models.model import Model
  from botorch.sampling.base import MCSampler
  from botorch.sampling.normal import SobolQMCNormalSampler
  from botorch.utils.transforms import concatenate_pending_points, t_batch_mode_transform
  from torch import Tensor
label_desc: Use image node_id 2 for calling the PairwiseMCPosteriorVariance obj's underlying member method code with example usage: obj.forward(X) and returns: mean_mc_var