code: def test_set_get_repeater():
      class TestSuggestion(Searcher):
          def __init__(self, index):
              self.index = index
              self.returned_result = []
              super().__init__(metric="result", mode="max")
  
          def suggest(self, trial_id):
              self.index += 1
              return {"score": self.index}
  
          def on_trial_complete(self, trial_id, result=None, **kwargs):
              self.returned_result.append(result)
  
      searcher = TestSuggestion(0)
      repeater1 = Repeater(searcher, repeat=3, set_index=False)
      for i in range(3):
          assert repeater1.suggest(f"test_{i}")["score"] == 1
      for i in range(2):  # An incomplete set of results
          assert repeater1.suggest(f"test_{i}_2")["score"] == 2
  
      # Restore a new one
      state = repeater1.get_state()
      del repeater1
      new_repeater = Repeater(searcher, repeat=1, set_index=True)
      new_repeater.set_state(state)
      assert new_repeater.repeat == 3
      assert new_repeater.suggest("test_2_2")["score"] == 2
      assert new_repeater.suggest("test_x")["score"] == 3
  
      # Report results
      for i in range(3):
          new_repeater.on_trial_complete(f"test_{i}", {"result": 2})
  
      for i in range(3):
          new_repeater.on_trial_complete(
              f"test_{i}_2", {"result": -i * 10}
          )
  
      assert len(new_repeater.searcher.returned_result) == 2
      assert new_repeater.searcher.returned_result[-1] == {
          "result": -10
      }
  
      # Finish the rest of the last trial group
      new_repeater.on_trial_complete("test_x", {"result": 3})
      assert new_repeater.suggest("test_y")["score"] == 3
      new_repeater.on_trial_complete("test_y", {"result": 3})
      assert len(new_repeater.searcher.returned_result) == 2
      assert new_repeater.suggest("test_z")["score"] == 3
      new_repeater.on_trial_complete("test_z", {"result": 3})
      assert len(new_repeater.searcher.returned_result) == 3
      assert new_repeater.searcher.returned_result[-1] == {"result": 3}
  
file_path: ray/python/ray/tune/tests/test_searcher_utils.py
imports: import pytest
  from ray.tune.search import BasicVariantGenerator
  from ray.tune.search.repeater import Repeater
  from ray.tune.search import Searcher, ConcurrencyLimiter
  from ray.tune.search.search_generator import SearchGenerator
label_desc: Use image node_id 6 for calling a global function with example usage: test_set_get_repeater() and returns: dict