code: def test_timeout(ray_start_4_cpus):
      """Test the timeout parameter.
  
      Start 4 tasks: Two succeed immediately, two after 1 second.
  
      After waiting for 0.5 seconds, the first two tasks should have returned.
      After waiting for up to 5 seconds, the other two tasks should have returned.
      But because the tasks take only 0.5 seconds to run, we should have waited
      way less than 5 seconds.
      """
      event_manager = RayEventManager()
  
      seen = set()
  
      def on_result(result: Any):
          seen.add(result)
  
      event_manager.track_futures(
          [
              succeeding.remote("a"),
              succeeding.remote("b"),
              sleeping.remote(1, "c"),
              sleeping.remote(1, "d"),
          ],
          on_result=on_result,
      )
  
      start = time.monotonic()
      event_manager.wait(num_results=None, timeout=0.5)
      assert "a" in seen
      assert "b" in seen
      assert "c" not in seen
      assert "d" not in seen
  
      event_manager.wait(num_results=None, timeout=5)
      taken = time.monotonic() - start
  
      assert "c" in seen
      assert "d" in seen
  
      # Should have returned much earlier than after 5 seconds
      assert taken < 3
  
      assert not event_manager._tracked_futures
  
file_path: ray/python/ray/air/tests/execution/test_event_manager.py
imports: import time
  from typing import Any, Type
  import pytest
  import ray
  from ray.air.execution._internal import Barrier
  from ray.air.execution._internal.event_manager import RayEventManager
  from ray.exceptions import RayTaskError
label_desc: Use image node_id 10 for calling a global function with example usage: test_timeout(ray_start_4_cpus) without return types