code: def test_affine_fidelity_cost_model(self):
      for dtype in (torch.float, torch.double):
          for batch_shape in ([], [2]):
              X = torch.rand(
                  *batch_shape, 3, 4, device=self.device, dtype=dtype
              )
              # test default parameters
              model = AffineFidelityCostModel()
              self.assertEqual(model.num_outputs, 1)
              self.assertEqual(model.fidelity_dims, [-1])
              self.assertEqual(model.fixed_cost, 0.01)
              cost = model(X)
              cost_exp = 0.01 + X[..., -1:]
              self.assertAllClose(cost, cost_exp)
              # test custom parameters
              fw = {2: 2.0, 0: 1.0}
              fc = random()
              model = AffineFidelityCostModel(
                  fidelity_weights=fw, fixed_cost=fc
              )
              self.assertEqual(model.fidelity_dims, [0, 2])
              self.assertEqual(model.fixed_cost, fc)
              cost = model(X)
              cost_exp = fc + sum(
                  v * X[..., i : i + 1] for i, v in fw.items()
              )
              self.assertAllClose(cost, cost_exp)
  
file_path: botorch/test/models/test_cost.py
imports: from random import random
  import torch
  from botorch.models.cost import AffineFidelityCostModel, FixedCostModel
  from botorch.utils.testing import BotorchTestCase
label_desc: Use image node_id 1 for calling the TestCostModels obj's underlying member method code with example usage: obj.test_affine_fidelity_cost_model() without return types