code: def test_KnowledgeGradient_helpers(self) -> None:
      model = KnowledgeGradient()
      model.fit(
          datasets=[self.dataset],
          metric_names=["L2NormMetric"],
          search_space_digest=SearchSpaceDigest(
              feature_names=self.feature_names,
              bounds=self.bounds,
          ),
      )
  
      # test _instantiate_KG
      posterior_tf = ScalarizedPosteriorTransform(
          weights=self.objective_weights
      )
  
      # test acquisition setting
      acq_function = _instantiate_KG(
          model=model.model,
          posterior_transform=posterior_tf,
          n_fantasies=10,
          qmc=True,
      )
      self.assertIsInstance(acq_function.sampler, SobolQMCNormalSampler)
      self.assertIsInstance(
          acq_function.posterior_transform, ScalarizedPosteriorTransform
      )
      self.assertEqual(acq_function.num_fantasies, 10)
  
      acq_function = _instantiate_KG(
          model=model.model,
          posterior_transform=posterior_tf,
          n_fantasies=10,
          qmc=False,
      )
      self.assertIsInstance(acq_function.sampler, IIDNormalSampler)
  
      acq_function = _instantiate_KG(
          model=model.model,
          posterior_transform=posterior_tf,
          qmc=False,
      )
      self.assertIsNone(acq_function.inner_sampler)
  
      acq_function = _instantiate_KG(
          model=model.model,
          posterior_transform=posterior_tf,
          qmc=True,
          X_pending=self.X_dummy,
      )
      self.assertIsNone(acq_function.inner_sampler)
      self.assertTrue(torch.equal(acq_function.X_pending, self.X_dummy))
  
      # test _get_best_point_acqf
      acq_function, non_fixed_idcs = model._get_best_point_acqf(
          objective_weights=self.objective_weights,
          outcome_constraints=self.outcome_constraints,
          X_observed=self.X_dummy,
      )
      self.assertIsInstance(acq_function, qSimpleRegret)
      self.assertIsInstance(acq_function.sampler, SobolQMCNormalSampler)
      self.assertIsNone(non_fixed_idcs)
  
      acq_function, non_fixed_idcs = model._get_best_point_acqf(
          objective_weights=self.objective_weights,
          outcome_constraints=self.outcome_constraints,
          X_observed=self.X_dummy,
          qmc=False,
      )
      self.assertIsInstance(acq_function.sampler, IIDNormalSampler)
      self.assertIsNone(non_fixed_idcs)
  
      with self.assertRaises(RuntimeError):
          model._get_best_point_acqf(
              objective_weights=self.objective_weights,
              outcome_constraints=self.outcome_constraints,
              X_observed=self.X_dummy,
              target_fidelities={1: 1.0},
          )
  
      # multi-fidelity tests
  
      model = KnowledgeGradient()
      model.fit(
          datasets=[self.dataset],
          metric_names=["L2NormMetric"],
          search_space_digest=SearchSpaceDigest(
              feature_names=self.feature_names,
              bounds=self.bounds,
              fidelity_features=[-1],
          ),
      )
  
      acq_function = _instantiate_KG(
          model=model.model,
          posterior_transform=posterior_tf,
          target_fidelities={2: 1.0},
          # pyre-fixme[6]: For 4th param expected `Optional[Tensor]` but got `int`.
          current_value=0,
      )
      self.assertIsInstance(
          acq_function, qMultiFidelityKnowledgeGradient
      )
  
      acq_function = _instantiate_KG(
          model=model.model,
          objective=LinearMCObjective(weights=self.objective_weights),
      )
      self.assertIsInstance(
          acq_function.inner_sampler, SobolQMCNormalSampler
      )
  
      # test error that target fidelity and fidelity weight indices must match
      with self.assertRaises(RuntimeError):
          _instantiate_KG(
              model=model.model,
              posterior_transform=posterior_tf,
              target_fidelities={1: 1.0},
              fidelity_weights={2: 1.0},
              # pyre-fixme[6]: For 5th param expected `Optional[Tensor]` but got
              #  `int`.
              current_value=0,
          )
  
      # test _get_best_point_acqf
      acq_function, non_fixed_idcs = model._get_best_point_acqf(
          objective_weights=self.objective_weights,
          outcome_constraints=self.outcome_constraints,
          X_observed=self.X_dummy,
          target_fidelities={2: 1.0},
      )
      self.assertIsInstance(
          acq_function, FixedFeatureAcquisitionFunction
      )
      self.assertIsInstance(
          acq_function.acq_func.sampler, SobolQMCNormalSampler
      )
      self.assertEqual(non_fixed_idcs, [0, 1])
  
      acq_function, non_fixed_idcs = model._get_best_point_acqf(
          objective_weights=self.objective_weights,
          outcome_constraints=self.outcome_constraints,
          X_observed=self.X_dummy,
          target_fidelities={2: 1.0},
          qmc=False,
      )
      self.assertIsInstance(
          acq_function, FixedFeatureAcquisitionFunction
      )
      self.assertIsInstance(
          acq_function.acq_func.sampler, IIDNormalSampler
      )
      self.assertEqual(non_fixed_idcs, [0, 1])
  
      # test error that fixed features are provided
      with self.assertRaises(RuntimeError):
          model._get_best_point_acqf(
              objective_weights=self.objective_weights,
              outcome_constraints=self.outcome_constraints,
              X_observed=self.X_dummy,
              qmc=False,
          )
  
      # test error if fixed features are also fidelity features
      with self.assertRaises(RuntimeError):
          model._get_best_point_acqf(
              objective_weights=self.objective_weights,
              outcome_constraints=self.outcome_constraints,
              X_observed=self.X_dummy,
              fixed_features={2: 2.0},
              target_fidelities={2: 1.0},
              qmc=False,
          )
  
imports: import dataclasses
  from typing import Any, Dict
  from unittest import mock
  import torch
  from ax.core.search_space import SearchSpaceDigest
  from ax.models.torch.botorch_kg import _instantiate_KG, KnowledgeGradient
  from ax.models.torch_base import TorchOptConfig
  from ax.utils.common.testutils import TestCase
  from ax.utils.testing.mock import fast_botorch_optimize
  from botorch.acquisition.analytic import PosteriorMean
  from botorch.acquisition.fixed_feature import FixedFeatureAcquisitionFunction
  from botorch.acquisition.knowledge_gradient import qMultiFidelityKnowledgeGradient
  from botorch.acquisition.monte_carlo import qSimpleRegret
  from botorch.acquisition.objective import LinearMCObjective, ScalarizedPosteriorTransform
  from botorch.exceptions.errors import UnsupportedError
  from botorch.models.transforms.input import Warp
  from botorch.sampling.normal import IIDNormalSampler, SobolQMCNormalSampler
  from botorch.utils.datasets import SupervisedDataset
label_desc: Use image node_id 4 for calling the KnowledgeGradientTest obj's underlying member method code with example usage: obj.test_KnowledgeGradient_helpers() without return types