code: def test_exception(self, fit_mock):
      # Check that training will not continue sampling if pyro raises an error
      class Dummy:
          counter = 0
  
          def __call__(self):
              self.counter += 1
              raise RuntimeError("Unable to sample new cfgs")
  
      fit_mock.side_effect = Dummy()
  
      with self.assertRaises(RuntimeError):
          self.gp_model._train(self.X_all, self.Y_all, do_optimize=True)
  
imports: from typing import Tuple
  import unittest.mock
  import gpytorch
  import numpy
  import pyro
  import torch
  from gpytorch.constraints.constraints import Interval
  from gpytorch.likelihoods.gaussian_likelihood import GaussianLikelihood
  from gpytorch.priors import HorseshoePrior
  from smac.configspace import ConfigurationSpace, UniformFloatHyperparameter
  from smac.model.gaussian_process.augmented_local_gaussian_process import AugmentedLocalGaussianProcess, GloballyAugmentedLocalGaussianProcess
  from smac.model.gaussian_process.gpytorch_gaussian_process import ExactGaussianProcessModel
  from ._test_boing_kernel import generate_kernel, generate_test_data
  from ._test_gp_gpytorch import TestGPGPyTorch
label_desc: Use image node_id 7 for calling the TestLGPGA obj's underlying member method code with example usage: obj.test_exception(fit_mock) without return types