class_docstr: Linear objective constructed from a weight tensor.
  
  For input `samples` and `mc_obj = LinearMCObjective(weights)`, this produces
  `mc_obj(samples) = sum_{i} weights[i] * samples[..., i]`
  
  Example:
      Example for a model with two outcomes:
  
      >>> weights = torch.tensor([0.75, 0.25])
      >>> linear_objective = LinearMCObjective(weights)
      >>> samples = sampler(posterior)
      >>> objective = linear_objective(samples)
class_docstr_tok: ["Linear","objective","constructed","from","a","weight","tensor",".","For","input","`","samples","`","and","`","mc_obj","=","LinearMCObjective","(","weights",")","`",",","this","produces","`","mc_obj","(","samples",")","=","sum_","{","i","}","weights","[","i","]","*","samples","[","...",",","i","]","`","Example",":","Example","for","a","model","with","two","outcomes",":",">",">",">","weights","=","torch.tensor","(","[","0.75",",","0.25","]",")",">",">",">","linear_objective","=","LinearMCObjective","(","weights",")",">",">",">","samples","=","sampler","(","posterior",")",">",">",">","objective","=","linear_objective","(","samples",")"]
docstr: Evaluate the linear 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 linear 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.
      """
      if samples.shape[-1] != self.weights.shape[-1]:
          raise RuntimeError(
              "Output shape of samples not equal to that of weights"
          )
      return torch.einsum("...m, m", [samples, self.weights])
  
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 LinearMCObjective obj's underlying member method code with example usage: obj.forward(samples, X) and returns: torch