code: def test_gp(self):
      for (
          iteration_fidelity,
          data_fidelities,
      ) in self.FIDELITY_TEST_PAIRS:
          num_dim = 1 + (iteration_fidelity is not None)
          if data_fidelities is not None:
              num_dim += len(data_fidelities)
          bounds = torch.zeros(2, num_dim)
          bounds[1] = 1
          for (
              batch_shape,
              m,
              dtype,
              lin_trunc,
              use_octf,
              use_intf,
          ) in itertools.product(
              (torch.Size(), torch.Size([2])),
              (1, 2),
              (torch.float, torch.double),
              (False, True),
              (False, True),
              (False, True),
          ):
              tkwargs = {"device": self.device, "dtype": dtype}
              octf = (
                  Standardize(m=m, batch_shape=batch_shape)
                  if use_octf
                  else None
              )
              intf = (
                  Normalize(d=num_dim, bounds=bounds)
                  if use_intf
                  else None
              )
              model, model_kwargs = self._get_model_and_data(
                  iteration_fidelity=iteration_fidelity,
                  data_fidelities=data_fidelities,
                  batch_shape=batch_shape,
                  m=m,
                  lin_truncated=lin_trunc,
                  outcome_transform=octf,
                  input_transform=intf,
                  **tkwargs,
              )
              mll = ExactMarginalLogLikelihood(model.likelihood, model)
              mll.to(**tkwargs)
              with warnings.catch_warnings():
                  warnings.filterwarnings(
                      "ignore", category=OptimizationWarning
                  )
                  fit_gpytorch_mll(
                      mll,
                      optimizer_kwargs={"options": {"maxiter": 1}},
                      sequential=False,
                  )
  
              # test init
              self.assertIsInstance(model.mean_module, ConstantMean)
              self.assertIsInstance(model.covar_module, ScaleKernel)
              if use_octf:
                  self.assertIsInstance(
                      model.outcome_transform, Standardize
                  )
              if use_intf:
                  self.assertIsInstance(
                      model.input_transform, Normalize
                  )
                  # permute output dim
                  train_X, train_Y, _ = model._transform_tensor_args(
                      X=model_kwargs["train_X"],
                      Y=model_kwargs["train_Y"],
                  )
                  # check that the train inputs have been transformed and set on the
                  # model
                  self.assertTrue(
                      torch.equal(model.train_inputs[0], intf(train_X))
                  )
  
              # test param sizes
              params = dict(model.named_parameters())
  
              if (
                  data_fidelities is not None
                  and len(data_fidelities) == 1
              ):
                  for p in params:
                      self.assertEqual(
                          params[p].numel(),
                          m * torch.tensor(batch_shape).prod().item(),
                      )
  
              # test posterior
              # test non batch evaluation
              X = torch.rand(*batch_shape, 3, num_dim, **tkwargs)
              expected_shape = batch_shape + torch.Size([3, m])
              posterior = model.posterior(X)
              self.assertIsInstance(posterior, GPyTorchPosterior)
              self.assertEqual(posterior.mean.shape, expected_shape)
              self.assertEqual(posterior.variance.shape, expected_shape)
              if use_octf:
                  # ensure un-transformation is applied
                  tmp_tf = model.outcome_transform
                  del model.outcome_transform
                  pp_tf = model.posterior(X)
                  model.outcome_transform = tmp_tf
                  expected_var = tmp_tf.untransform_posterior(
                      pp_tf
                  ).variance
                  self.assertAllClose(posterior.variance, expected_var)
  
              # test batch evaluation
              X = torch.rand(2, *batch_shape, 3, num_dim, **tkwargs)
              expected_shape = (
                  torch.Size([2]) + batch_shape + torch.Size([3, m])
              )
              posterior = model.posterior(X)
              self.assertIsInstance(posterior, GPyTorchPosterior)
              self.assertEqual(posterior.mean.shape, expected_shape)
              self.assertEqual(posterior.variance.shape, expected_shape)
              if use_octf:
                  # ensure un-transformation is applied
                  tmp_tf = model.outcome_transform
                  del model.outcome_transform
                  pp_tf = model.posterior(X)
                  model.outcome_transform = tmp_tf
                  expected_var = tmp_tf.untransform_posterior(
                      pp_tf
                  ).variance
                  self.assertAllClose(posterior.variance, expected_var)
  
imports: import itertools
  import warnings
  from typing import Tuple
  import torch
  from botorch.exceptions.errors import UnsupportedError
  from botorch.exceptions.warnings import OptimizationWarning
  from botorch.fit import fit_gpytorch_mll
  from botorch.models.gp_regression_fidelity import FixedNoiseMultiFidelityGP, SingleTaskMultiFidelityGP
  from botorch.models.transforms import Normalize, Standardize
  from botorch.posteriors import GPyTorchPosterior
  from botorch.sampling import SobolQMCNormalSampler
  from botorch.utils.datasets import SupervisedDataset
  from botorch.utils.testing import _get_random_data, BotorchTestCase
  from gpytorch.kernels.scale_kernel import ScaleKernel
  from gpytorch.likelihoods import FixedNoiseGaussianLikelihood
  from gpytorch.means import ConstantMean
  from gpytorch.mlls.exact_marginal_log_likelihood import ExactMarginalLogLikelihood
  from torch import Tensor
label_desc: Use image node_id 3 for calling the TestSingleTaskMultiFidelityGP obj's underlying member method code with example usage: obj.test_gp() without return types