class_docstr: Learned preference objective constructed from a preference model.
  
  For input `samples`, it samples each individual sample again from the latent
  preference posterior distribution using `pref_model` and return the posterior mean.
  
  Example:
      >>> train_X = torch.rand(2, 2)
      >>> train_comps = torch.LongTensor([[0, 1]])
      >>> pref_model = PairwiseGP(train_X, train_comps)
      >>> learned_pref_obj = LearnedObjective(pref_model)
      >>> samples = sampler(posterior)
      >>> objective = learned_pref_obj(samples)
class_docstr_tok: ["Learned","preference","objective","constructed","from","a","preference","model",".","For","input","`","samples","`",",","it","samples","each","individual","sample","again","from","the","latent","preference","posterior","distribution","using","`","pref_model","`","and","return","the","posterior","mean",".","Example",":",">",">",">","train_X","=","torch.rand","(","2",",","2",")",">",">",">","train_comps","=","torch.LongTensor","(","[","[","0",",","1","]","]",")",">",">",">","pref_model","=","PairwiseGP","(","train_X",",","train_comps",")",">",">",">","learned_pref_obj","=","LearnedObjective","(","pref_model",")",">",">",">","samples","=","sampler","(","posterior",")",">",">",">","objective","=","learned_pref_obj","(","samples",")"]
docstr: Args:
      pref_model: A BoTorch model, which models the latent preference/utility
          function. Given an input tensor of size
          `sample_size x batch_shape x q x d`, its `posterior` method should
          return a `Posterior` object with single outcome representing the
          utility values of the input.
      sample_shape: Determines the number of preference-model samples drawn
          *per outcome-model sample* when the `LearnedObjective` is called.
          Note that this is an additional layer of sampling relative to what
          is needed when evaluating most MC acquisition functions in order to
          account for uncertainty in the preference model. If `None`, it will
          default to `torch.Size([16])`, so that 16 samples will be drawn
          from the preference model at each outcome sample. This number is
          relatively high because sampling from the preference model is general
          cheap relative to generating the outcome model posterior.
code: def __init__(
      self,
      pref_model: Model,
      sample_shape: Optional[torch.Size] = None,
      seed: Optional[int] = None,
  ):
      r"""
      Args:
          pref_model: A BoTorch model, which models the latent preference/utility
              function. Given an input tensor of size
              `sample_size x batch_shape x q x d`, its `posterior` method should
              return a `Posterior` object with single outcome representing the
              utility values of the input.
          sample_shape: Determines the number of preference-model samples drawn
              *per outcome-model sample* when the `LearnedObjective` is called.
              Note that this is an additional layer of sampling relative to what
              is needed when evaluating most MC acquisition functions in order to
              account for uncertainty in the preference model. If `None`, it will
              default to `torch.Size([16])`, so that 16 samples will be drawn
              from the preference model at each outcome sample. This number is
              relatively high because sampling from the preference model is general
              cheap relative to generating the outcome model posterior.
      """
      super().__init__()
      self.pref_model = pref_model
      if isinstance(pref_model, DeterministicModel):
          assert sample_shape is None
          self.sampler = None
      else:
          if sample_shape is None:
              sample_shape = torch.Size([DEFAULT_NUM_PREF_SAMPLES])
          # using an IIDNormalSampler instead of a SobolQMCNormalSampler by default
          # because SobolQMCNormalSampler can support up to 21201 total samples and
          # becomes noticeably slower than uniform sampling when the sample size is
          # large.
          self.sampler = IIDNormalSampler(
              sample_shape=sample_shape, seed=seed
          )
          self.sampler.batch_range_override = (1, -1)
  
imports: from __future__ import annotations
  import inspect
  import warnings
  from abc import ABC, abstractmethod
  from typing import Callable, List, Optional, TYPE_CHECKING, Union
  import torch
  from botorch.exceptions.errors import BotorchTensorDimensionError, UnsupportedError
  from botorch.exceptions.warnings import InputDataWarning
  from botorch.models.model import Model
  from botorch.models.transforms.outcome import Standardize
  from botorch.posteriors.gpytorch import GPyTorchPosterior, scalarize_posterior
  from botorch.sampling import IIDNormalSampler
  from botorch.utils import apply_constraints
  from gpytorch.distributions import MultitaskMultivariateNormal, MultivariateNormal
  from linear_operator.operators.dense_linear_operator import to_linear_operator
  from torch import Tensor
  from torch.nn import Module
  from botorch.models.deterministic import DeterministicModel
label_desc: Use image node_id 1 to create a new LearnedObjective object from inherited base classes: MCAcquisitionObjective with example: obj = LearnedObjective(pref_model, sample_shape, seed)