code: def test_q_max_value_entropy(self):
      for dtype in (torch.float, torch.double):
          torch.manual_seed(7)
          mm = MESMockModel()
          with self.assertRaises(TypeError):
              qMaxValueEntropy(mm)
  
          candidate_set = torch.rand(
              1000, 2, device=self.device, dtype=dtype
          )
  
          # test error in case of batch GP model
          mm = MESMockModel(batch_shape=torch.Size([2]))
          with self.assertRaises(NotImplementedError):
              qMaxValueEntropy(mm, candidate_set, num_mv_samples=10)
          mm = MESMockModel()
          train_inputs = torch.rand(
              5, 10, 2, device=self.device, dtype=dtype
          )
          with self.assertRaises(NotImplementedError):
              qMaxValueEntropy(
                  mm,
                  candidate_set,
                  num_mv_samples=10,
                  train_inputs=train_inputs,
              )
  
          # test that init works if batch_shape is not implemented on the model
          mm = NoBatchShapeMESMockModel()
          qMaxValueEntropy(
              mm,
              candidate_set,
              num_mv_samples=10,
          )
  
          # test error when number of outputs > 1 and no transform is given.
          mm = MESMockModel()
          mm._num_outputs = 2
          with self.assertRaises(UnsupportedError):
              qMaxValueEntropy(mm, candidate_set, num_mv_samples=10)
  
          # test with X_pending is None
          mm = MESMockModel()
          train_inputs = torch.rand(
              10, 2, device=self.device, dtype=dtype
          )
          mm.train_inputs = (train_inputs,)
          qMVE = qMaxValueEntropy(mm, candidate_set, num_mv_samples=10)
  
          # test initialization
          self.assertEqual(qMVE.num_fantasies, 16)
          self.assertEqual(qMVE.num_mv_samples, 10)
          self.assertIsInstance(qMVE.sampler, SobolQMCNormalSampler)
          self.assertEqual(qMVE.sampler.sample_shape, torch.Size([128]))
          self.assertIsInstance(
              qMVE.fantasies_sampler, SobolQMCNormalSampler
          )
          self.assertEqual(
              qMVE.fantasies_sampler.sample_shape, torch.Size([16])
          )
          self.assertEqual(qMVE.use_gumbel, True)
          self.assertEqual(
              qMVE.posterior_max_values.shape, torch.Size([10, 1])
          )
  
          # test evaluation
          X = torch.rand(1, 2, device=self.device, dtype=dtype)
          self.assertEqual(qMVE(X).shape, torch.Size([1]))
  
          # test set X pending to None in case of _init_model exists
          qMVE.set_X_pending(None)
          self.assertEqual(qMVE.model, qMVE._init_model)
  
          # test with use_gumbel = False
          qMVE = qMaxValueEntropy(
              mm, candidate_set, num_mv_samples=10, use_gumbel=False
          )
          self.assertEqual(qMVE(X).shape, torch.Size([1]))
  
          # test with X_pending is not None
          with mock.patch.object(
              MESMockModel, "fantasize", return_value=mm
          ) as patch_f:
              qMVE = qMaxValueEntropy(
                  mm,
                  candidate_set,
                  num_mv_samples=10,
                  X_pending=torch.rand(
                      1, 2, device=self.device, dtype=dtype
                  ),
              )
              patch_f.assert_called_once()
  
          # Test with multi-output model w/ transform.
          mm = MESMockModel(num_outputs=2)
          pt = ScalarizedPosteriorTransform(
              weights=torch.ones(2, device=self.device, dtype=dtype)
          )
          for gumbel in (True, False):
              qMVE = qMaxValueEntropy(
                  mm,
                  candidate_set,
                  num_mv_samples=10,
                  use_gumbel=gumbel,
                  posterior_transform=pt,
              )
              self.assertEqual(qMVE(X).shape, torch.Size([1]))
  
imports: from typing import Callable, Optional
  from unittest import mock
  import torch
  from botorch.acquisition.cost_aware import InverseCostWeightedUtility
  from botorch.acquisition.max_value_entropy_search import _sample_max_value_Gumbel, _sample_max_value_Thompson, qLowerBoundMaxValueEntropy, qMaxValueEntropy, qMultiFidelityLowerBoundMaxValueEntropy, qMultiFidelityMaxValueEntropy
  from botorch.acquisition.objective import PosteriorTransform, ScalarizedPosteriorTransform
  from botorch.exceptions.errors import UnsupportedError
  from botorch.posteriors import GPyTorchPosterior
  from botorch.sampling.normal import SobolQMCNormalSampler
  from botorch.utils.testing import BotorchTestCase, MockModel, MockPosterior
  from gpytorch.distributions import MultitaskMultivariateNormal, MultivariateNormal
  from torch import Tensor
label_desc: Use image node_id 1 for calling the TestMaxValueEntropySearch obj's underlying member method code with example usage: obj.test_q_max_value_entropy() without return types