class_docstr: Penalized MC objective.
  
  Allows to construct a penalized MC-objective by adding a penalty term to
  the original objective.
  
      mc_acq(X) = objective(X) + penalty_objective(X)
  
  Note: PenalizedMCObjective allows adding penalty at the MCObjective level,
  different from the AcquisitionFunction level in PenalizedAcquisitionFunction.
  
  Example:
      >>> regularization_parameter = 0.01
      >>> init_point = torch.zeros(3) # assume data dim is 3
      >>> objective = lambda Y, X: torch.sqrt(Y).sum(dim=-1)
      >>> l1_penalty_objective = L1PenaltyObjective(init_point=init_point)
      >>> l1_penalized_objective = PenalizedMCObjective(
              objective, l1_penalty_objective, regularization_parameter
          )
      >>> samples = sampler(posterior)
              objective, l1_penalty_objective, regularization_parameter
docstr: Penalized MC objective.
  
  Args:
      objective: A callable `f(samples, X)` mapping a
          `sample_shape x batch-shape x q x m`-dim Tensor `samples` and
          an optional `batch-shape x q x d`-dim Tensor `X` to a
          `sample_shape x batch-shape x q`-dim Tensor of objective values.
      penalty_objective: A torch.nn.Module `f(X)` that takes in a
          `batch-shape x q x d`-dim Tensor `X` and outputs a
          `1 x batch-shape x q`-dim Tensor of penalty objective values.
      regularization_parameter: weight of the penalty (regularization) term
      expand_dim: dim to expand penalty_objective to match with objective when
          fully bayesian model is used. If None, no expansion is performed.
docstr_tok: ["Penalized","MC","objective",".","Args",":","objective",":","A","callable","`","f","(","samples",",","X",")","`","mapping","a","`","sample_shape","x","batch-shape","x","q","x","m","`","-dim","Tensor","`","samples","`","and","an","optional","`","batch-shape","x","q","x","d","`","-dim","Tensor","`","X","`","to","a","`","sample_shape","x","batch-shape","x","q","`","-dim","Tensor","of","objective","values",".","penalty_objective",":","A","torch.nn.Module","`","f","(","X",")","`","that","takes","in","a","`","batch-shape","x","q","x","d","`","-dim","Tensor","`","X","`","and","outputs","a","`","1","x","batch-shape","x","q","`","-dim","Tensor","of","penalty","objective","values",".","regularization_parameter",":","weight","of","the","penalty","(","regularization",")","term","expand_dim",":","dim","to","expand","penalty_objective","to","match","with","objective","when","fully","bayesian","model","is","used",".","If","None",",","no","expansion","is","performed","."]
code: def __init__(
      self,
      objective: Callable[[Tensor, Optional[Tensor]], Tensor],
      penalty_objective: torch.nn.Module,
      regularization_parameter: float,
      expand_dim: Optional[int] = None,
  ) -> None:
      r"""Penalized MC objective.
  
      Args:
          objective: A callable `f(samples, X)` mapping a
              `sample_shape x batch-shape x q x m`-dim Tensor `samples` and
              an optional `batch-shape x q x d`-dim Tensor `X` to a
              `sample_shape x batch-shape x q`-dim Tensor of objective values.
          penalty_objective: A torch.nn.Module `f(X)` that takes in a
              `batch-shape x q x d`-dim Tensor `X` and outputs a
              `1 x batch-shape x q`-dim Tensor of penalty objective values.
          regularization_parameter: weight of the penalty (regularization) term
          expand_dim: dim to expand penalty_objective to match with objective when
              fully bayesian model is used. If None, no expansion is performed.
      """
      super().__init__(objective=objective)
      self.penalty_objective = penalty_objective
      self.regularization_parameter = regularization_parameter
      self.expand_dim = expand_dim
  
imports: from __future__ import annotations
  import math
  from typing import Any, Callable, List, Optional
  import torch
  from botorch.acquisition.acquisition import AcquisitionFunction
  from botorch.acquisition.analytic import AnalyticAcquisitionFunction
  from botorch.acquisition.objective import GenericMCObjective
  from botorch.exceptions import UnsupportedError
  from torch import Tensor
label_desc: Use image node_id 1 to create a new PenalizedMCObjective object from inherited base classes: GenericMCObjective with example: obj = PenalizedMCObjective(objective, penalty_objective, regularization_parameter, expand_dim)