class_docstr: Objective generated from a generic callable.
  
  Allows to construct arbitrary MC-objective functions from a generic
  callable. In order to be able to use gradient-based acquisition function
  optimization it should be possible to backpropagate through the callable.
  
  Example:
      >>> generic_objective = GenericMCObjective(
              lambda Y, X: torch.sqrt(Y).sum(dim=-1),
          )
      >>> samples = sampler(posterior)
      >>> objective = generic_objective(samples)
class_docstr_tok: ["Objective","generated","from","a","generic","callable",".","Allows","to","construct","arbitrary","MC-objective","functions","from","a","generic","callable",".","In","order","to","be","able","to","use","gradient-based","acquisition","function","optimization","it","should","be","possible","to","backpropagate","through","the","callable",".","Example",":",">",">",">","generic_objective","=","GenericMCObjective","(","lambda","Y",",","X",":","torch.sqrt","(","Y",")",".sum","(","dim=-1",")",",",")",">",">",">","samples","=","sampler","(","posterior",")",">",">",">","objective","=","generic_objective","(","samples",")"]
docstr: Evaluate the objective on the samples.
  
  Args:
      samples: A `sample_shape x batch_shape x q x m`-dim Tensors of
          samples from a model posterior.
      X: A `batch_shape x q x d`-dim tensor of inputs. Relevant only if
          the objective depends on the inputs explicitly.
  
  Returns:
      A `sample_shape x batch_shape x q`-dim Tensor of objective values.
code: def forward(
      self, samples: Tensor, X: Optional[Tensor] = None
  ) -> Tensor:
      r"""Evaluate the objective on the samples.
  
      Args:
          samples: A `sample_shape x batch_shape x q x m`-dim Tensors of
              samples from a model posterior.
          X: A `batch_shape x q x d`-dim tensor of inputs. Relevant only if
              the objective depends on the inputs explicitly.
  
      Returns:
          A `sample_shape x batch_shape x q`-dim Tensor of objective values.
      """
      return self.objective(samples, X=X)
  
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 2 for calling the GenericMCObjective obj's underlying member method code with example usage: obj.forward(samples, X) and returns: self