docstr: Test that algo drops out when exploiting an already explored region.
docstr_tok: ["Test","that","algo","drops","out","when","exploiting","an","already","explored","region","."]
code: def test_stuck_exploiting(self, monkeypatch):
      """Test that algo drops out when exploiting an already explored region."""
      algo = self.create_algo()
  
      trials = algo.space.sample(1)
      assert trials is not None
  
      # Mock sampling so that always returns the same trials
      def sample(self, n_samples: int = 1, seed=None) -> list[Trial]:
          return trials
  
      def _suggest_random(self: TPE, num: int) -> list[Trial]:
          return self._suggest(num, sample)
  
      monkeypatch.setattr(TPE, "_suggest_random", _suggest_random)
      monkeypatch.setattr(TPE, "_suggest_bo", _suggest_random)
  
      with pytest.raises(RuntimeError):
          self.force_observe(2, algo)
  
      assert algo.n_observed == 1
      assert algo.n_suggested == 1
  
imports: from __future__ import annotations
  import copy
  import itertools
  import timeit
  from typing import ClassVar
  import numpy
  import numpy
  import pytest
  from scipy.stats import norm
  from orion.algo.space import Categorical, Fidelity, Integer, Real, Space
  from orion.algo.tpe import TPE, CategoricalSampler, GMMSampler, adaptive_parzen_estimator, compute_max_ei_point, ramp_up_weights
  from orion.core.utils import backward, format_trials
  from orion.core.worker.algo_wrappers.space_transform import SpaceTransform
  from orion.core.worker.primary_algo import create_algo
  from orion.core.worker.transformer import build_required_space
  from orion.core.worker.trial import Trial
  from orion.testing.algo import BaseAlgoTests, TestPhase, first_phase_only
label_desc: Use image node_id 8 for calling the TestTPE obj's underlying member method code with example usage: obj.test_stuck_exploiting(monkeypatch) and returns: trials, self