class_docstr: Tests for the algo Hyperband.
class_docstr_tok: ["Tests","for","the","algo","Hyperband","."]
docstr: Test that sampling collisions are handled between different hyperband execution.
docstr_tok: ["Test","that","sampling","collisions","are","handled","between","different","hyperband","execution","."]
code: def test_suggest_duplicates_between_execution(
      self,
      monkeypatch,
      hyperband: Hyperband,
      budgets: list[BudgetTuple],
  ):
      """Test that sampling collisions are handled between different hyperband execution."""
      hyperband.repetitions = 2
      bracket = HyperbandBracket(hyperband, budgets, 1)
      hyperband.brackets = [bracket]
      assert bracket.owner is hyperband
  
      for i in range(9):
          force_observe(
              hyperband, create_trial_for_hb((1, i), objective=i)
          )
  
      for i in range(3):
          force_observe(
              hyperband, create_trial_for_hb((3, i), objective=i)
          )
  
      force_observe(hyperband, create_trial_for_hb((9, 0), objective=0))
  
      assert not hyperband.is_done
  
      # lr:7 and lr:8 are already sampled in first repetition, they should not be present
      # in second repetition. Samples with lr:7 and lr:8 will be ignored.
  
      # (9, 0) already exists
      candidates_for_epoch_9_bracket = [(9, 0), (9, 2), (9, 3), (9, 10)]
      # (9, 1) -> (3, 1) already promoted in last repetition
      # (9, 3) sampled for previous bracket
      candidates_for_epoch_3_bracket = [
          (9, 1),
          (9, 3),
          (9, 4),
          (9, 5),
          (9, 11),
      ]
      # (9, 0) -> (1, 0) already sampled in last repetition
      # (9, 8) -> (1, 8) already sampled in last repetition
      candidates_for_epoch_1_bracket = [
          (9, 0),
          (9, 8),
          (9, 12),
          (9, 13),
      ]
  
      zhe_point = list(
          map(
              create_trial_for_hb,
              candidates_for_epoch_9_bracket
              + candidates_for_epoch_3_bracket
              + candidates_for_epoch_1_bracket,
          )
      )
  
      hyperband._refresh_brackets()
      mock_samples(hyperband, zhe_point)
      zhe_samples = hyperband.suggest(100)
      assert zhe_samples is not None
      assert len(zhe_samples) == 8
      assert zhe_samples[0].params == {"epoch": 9, "lr": 2}
      assert zhe_samples[1].params == {"epoch": 9, "lr": 3}
      assert zhe_samples[2].params == {"epoch": 9, "lr": 10}
      assert zhe_samples[3].params == {"epoch": 3, "lr": 4}
      assert zhe_samples[4].params == {"epoch": 3, "lr": 5}
      assert zhe_samples[5].params == {"epoch": 3, "lr": 11}
      assert zhe_samples[6].params == {"epoch": 1, "lr": 12}
      assert zhe_samples[7].params == {"epoch": 1, "lr": 13}
  
imports: from __future__ import annotations
  import copy
  import logging
  import typing
  from typing import Any, ClassVar, Sequence
  import numpy
  import pytest
  from orion.algo.hyperband import BudgetTuple, Hyperband, HyperbandBracket, RungDict, compute_budgets
  from orion.algo.space import Fidelity, Integer, Real, Space
  from orion.core.utils.flatten import flatten
  from orion.core.worker.primary_algo import SpaceTransform
  from orion.core.worker.trial import Trial
  from orion.testing.algo import BaseAlgoTests, TestPhase
  from orion.testing.trial import compare_trials, create_trial
label_desc: Use image node_id 10 for calling the TestHyperband obj's underlying member method code with example usage: obj.test_suggest_duplicates_between_execution(monkeypatch, hyperband, budgets) without return types