code: def _wait_for_slots(
      min_slots_expected: int, max_ticks: int = 60 * 2
  ) -> List[Dict[str, Any]]:
      for _ in range(max_ticks):
          slots = _fetch_slots()
          if len(slots) >= min_slots_expected:
              return slots
          time.sleep(1)
  
      pytest.fail(
          f"Didn't detect {min_slots_expected} slots within {max_ticks} seconds"
      )
  
imports: import contextlib
  import json
  import subprocess
  import time
  from typing import Any, Dict, Iterator, List, Optional, cast
  import pytest
  from determined.common.api.bindings import experimentv1State, get_GetSlot
  from tests import api_utils
  from tests import config
  from tests import experiment
  from .test_users import logged_in_user
  from .utils import assert_command_succeeded, run_zero_slot_command, wait_for_command_state
label_desc: Use image node_id 3 for calling a global function with example usage: _wait_for_slots(min_slots_expected, max_ticks) and returns: slots