class_docstr: A cost-aware utility using inverse cost weighting based on a model.
  
  Computes the cost-aware utility by inverse-weighting samples
  `U = (u_1, ..., u_N)` of the increase in utility. If `use_mean=True`, this
  uses the posterior mean `mean_cost` of the cost model, i.e.
  `weighted utility = mean(U) / mean_cost`. If `use_mean=False`, it uses
  samples `C = (c_1, ..., c_N)` from the posterior of the cost model and
  performs the inverse weighting on the sample level:
  `weighted utility = mean(u_1 / c_1, ..., u_N / c_N)`.
  
  The cost is additive across multiple elements of a q-batch.
class_docstr_tok: ["A","cost-aware","utility","using","inverse","cost","weighting","based","on","a","model",".","Computes","the","cost-aware","utility","by","inverse-weighting","samples","`","U","=","(","u_1",",","...",",","u_N",")","`","of","the","increase","in","utility",".","If","`","use_mean=True","`",",","this","uses","the","posterior","mean","`","mean_cost","`","of","the","cost","model",",","i.e",".","`","weighted","utility","=","mean","(","U",")","\/","mean_cost","`",".","If","`","use_mean=False","`",",","it","uses","samples","`","C","=","(","c_1",",","...",",","c_N",")","`","from","the","posterior","of","the","cost","model","and","performs","the","inverse","weighting","on","the","sample","level",":","`","weighted","utility","=","mean","(","u_1","\/","c_1",",","...",",","u_N","\/","c_N",")","`",".","The","cost","is","additive","across","multiple","elements","of","a","q-batch","."]
docstr: Cost-aware utility that weights increase in utility by inverse cost.
  
  Args:
      cost_model: A model of the cost of evaluating a candidate
          set `X`, where `X` are the same features as in the model for the
          acquisition function this is to be used with. If no cost_objective
          is specified, the outputs are required to be non-negative.
      use_mean: If True, use the posterior mean, otherwise use posterior
          samples from the cost model.
      cost_objective: If specified, transform the posterior mean / the
          posterior samples from the cost model. This can be used e.g. to
          un-transform predictions/samples of a cost model fit on the
          log-transformed cost (often done to ensure non-negativity). If the
          cost model is multi-output, then by default this will sum the cost
          across outputs.
      min_cost: A value used to clamp the cost samples so that they are not
          too close to zero, which may cause numerical issues.
  Returns:
      The inverse-cost-weighted utility.
docstr_tok: ["Cost-aware","utility","that","weights","increase","in","utility","by","inverse","cost",".","Args",":","cost_model",":","A","model","of","the","cost","of","evaluating","a","candidate","set","`","X","`",",","where","`","X","`","are","the","same","features","as","in","the","model","for","the","acquisition","function","this","is","to","be","used","with",".","If","no","cost_objective","is","specified",",","the","outputs","are","required","to","be","non-negative",".","use_mean",":","If","True",",","use","the","posterior","mean",",","otherwise","use","posterior","samples","from","the","cost","model",".","cost_objective",":","If","specified",",","transform","the","posterior","mean","\/","the","posterior","samples","from","the","cost","model",".","This","can","be","used","e.g",".","to","un-transform","predictions\/samples","of","a","cost","model","fit","on","the","log-transformed","cost","(","often","done","to","ensure","non-negativity",")",".","If","the","cost","model","is","multi-output",",","then","by","default","this","will","sum","the","cost","across","outputs",".","min_cost",":","A","value","used","to","clamp","the","cost","samples","so","that","they","are","not","too","close","to","zero",",","which","may","cause","numerical","issues",".","Returns",":","The","inverse-cost-weighted","utility","."]
code: def __init__(
      self,
      cost_model: Union[DeterministicModel, GPyTorchModel],
      use_mean: bool = True,
      cost_objective: Optional[MCAcquisitionObjective] = None,
      min_cost: float = 1e-2,
  ) -> None:
      r"""Cost-aware utility that weights increase in utility by inverse cost.
  
      Args:
          cost_model: A model of the cost of evaluating a candidate
              set `X`, where `X` are the same features as in the model for the
              acquisition function this is to be used with. If no cost_objective
              is specified, the outputs are required to be non-negative.
          use_mean: If True, use the posterior mean, otherwise use posterior
              samples from the cost model.
          cost_objective: If specified, transform the posterior mean / the
              posterior samples from the cost model. This can be used e.g. to
              un-transform predictions/samples of a cost model fit on the
              log-transformed cost (often done to ensure non-negativity). If the
              cost model is multi-output, then by default this will sum the cost
              across outputs.
          min_cost: A value used to clamp the cost samples so that they are not
              too close to zero, which may cause numerical issues.
      Returns:
          The inverse-cost-weighted utility.
      """
      super().__init__()
      if cost_objective is None:
          if cost_model.num_outputs == 1:
              cost_objective = IdentityMCObjective()
          else:
              # sum over outputs
              cost_objective = GenericMCObjective(
                  lambda Y, X: Y.sum(dim=-1)
              )
  
      self.cost_model = cost_model
      self.cost_objective = cost_objective
      self._use_mean = use_mean
      self._min_cost = min_cost
  
imports: from __future__ import annotations
  import warnings
  from abc import ABC, abstractmethod
  from typing import Any, Callable, Optional, Union
  import torch
  from botorch import settings
  from botorch.acquisition.objective import GenericMCObjective, IdentityMCObjective, MCAcquisitionObjective
  from botorch.exceptions.warnings import CostAwareWarning
  from botorch.models.deterministic import DeterministicModel
  from botorch.models.gpytorch import GPyTorchModel
  from botorch.sampling.base import MCSampler
  from torch import Tensor
  from torch.nn import Module
label_desc: Use image node_id 1 to create a new InverseCostWeightedUtility object from inherited base classes: CostAwareUtility with example: obj = InverseCostWeightedUtility(cost_model, use_mean, cost_objective, min_cost)