class_docstr: Deterministic, affine cost model operating on fidelity parameters.
  
  For each (q-batch) element of a candidate set `X`, this module computes a
  cost of the form
  
      cost = fixed_cost + sum_j weights[j] * X[fidelity_dims[j]]
  
  For a full worked example, see the
  `tutorial <https://botorch.org/tutorials/multi_fidelity_bo>`_ on continuous
  multi-fidelity Bayesian Optimization.
  
  Example:
      >>> from botorch.models import AffineFidelityCostModel
      >>> from botorch.acquisition.cost_aware import InverseCostWeightedUtility
      >>> cost_model = AffineFidelityCostModel(
      >>>    fidelity_weights={6: 1.0}, fixed_cost=5.0
      >>> )
      >>> cost_aware_utility = InverseCostWeightedUtility(cost_model=cost_model)
class_docstr_tok: ["Deterministic",",","affine","cost","model","operating","on","fidelity","parameters",".","For","each","(","q-batch",")","element","of","a","candidate","set","`","X","`",",","this","module","computes","a","cost","of","the","form","cost","=","fixed_cost","+","sum_j","weights","[","j","]","*","X","[","fidelity_dims","[","j","]","]","For","a","full","worked","example",",","see","the","`","tutorial","<","https",":","\/\/botorch.org\/tutorials\/multi_fidelity_bo",">","`","_","on","continuous","multi-fidelity","Bayesian","Optimization",".","Example",":",">",">",">","from","botorch.models","import","AffineFidelityCostModel",">",">",">","from","botorch.acquisition.cost_aware","import","InverseCostWeightedUtility",">",">",">","cost_model","=","AffineFidelityCostModel","(",">",">",">","fidelity_weights=","{","6",":","1.0","}",",","fixed_cost=5.0",">",">",">",")",">",">",">","cost_aware_utility","=","InverseCostWeightedUtility","(","cost_model=cost_model",")"]
docstr: Evaluate the cost on a candidate set X.
  
  Computes a cost of the form
  
      cost = fixed_cost + sum_j weights[j] * X[fidelity_dims[j]]
  
  for each element of the q-batch
  
  Args:
      X: A `batch_shape x q x d'`-dim tensor of candidate points.
  
  Returns:
      A `batch_shape x q x 1`-dim tensor of costs.
docstr_tok: ["Evaluate","the","cost","on","a","candidate","set","X.","Computes","a","cost","of","the","form","cost","=","fixed_cost","+","sum_j","weights","[","j","]","*","X","[","fidelity_dims","[","j","]","]","for","each","element","of","the","q-batch","Args",":","X",":","A","`","batch_shape","x","q","x","d","'","`","-dim","tensor","of","candidate","points",".","Returns",":","A","`","batch_shape","x","q","x","1","`","-dim","tensor","of","costs","."]
code: def forward(self, X: Tensor) -> Tensor:
      r"""Evaluate the cost on a candidate set X.
  
      Computes a cost of the form
  
          cost = fixed_cost + sum_j weights[j] * X[fidelity_dims[j]]
  
      for each element of the q-batch
  
      Args:
          X: A `batch_shape x q x d'`-dim tensor of candidate points.
  
      Returns:
          A `batch_shape x q x 1`-dim tensor of costs.
      """
      # TODO: Consider different aggregation (i.e. max) across q-batch
      lin_cost = torch.einsum(
          "...f,f", X[..., self.fidelity_dims], self.weights.to(X)
      )
      return self.fixed_cost + lin_cost.unsqueeze(-1)
  
file_path: botorch/botorch/models/cost.py
imports: from __future__ import annotations
  from typing import Dict, Optional
  import torch
  from botorch.models.deterministic import DeterministicModel
  from torch import Tensor
label_desc: Use image node_id 2 for calling the AffineFidelityCostModel obj's underlying member method code with example usage: obj.forward(X) and returns: unknown