code: def test_cancel_stress(shutdown_only):
      ray.init()
  
      @ray.remote
      class Actor:
          async def sleep(self):
              await asyncio.sleep(1000)
  
      actors = [Actor.remote() for _ in range(30)]
  
      refs = []
      for _ in range(20):
          for actor in actors:
              for i in range(100):
                  ref = actor.sleep.remote()
                  refs.append(ref)
                  if i % 2 == 0:
                      ray.cancel(ref)
  
      for ref in refs:
          ray.cancel(ref)
  
      for ref in refs:
          with pytest.raises(
              (ray.exceptions.TaskCancelledError, TaskCancelledError)
          ):
              ray.get(ref)
  
imports: import asyncio
  import os
  import sys
  import time
  from collections import defaultdict
  import pytest
  import ray
  from ray._private.test_utils import SignalActor, wait_for_condition
  from ray.exceptions import TaskCancelledError
  from ray.util.state import list_tasks
label_desc: Use image node_id 9 for calling a global function with example usage: test_cancel_stress(shutdown_only) without return types