code: def test_cancel_chain(ray_start_regular, use_force):
      with ray_start_client_server() as ray:
          SignalActor = create_remote_signal_actor(ray)
          signaler = SignalActor.remote()
  
          @ray.remote
          def wait_for(t):
              return ray.get(t[0])
  
          obj1 = wait_for.remote([signaler.wait.remote()])
          obj2 = wait_for.remote([obj1])
          obj3 = wait_for.remote([obj2])
          obj4 = wait_for.remote([obj3])
  
          assert len(ray.wait([obj1], timeout=0.1)[0]) == 0
          ray.cancel(obj1, force=use_force)
          for ob in [obj1, obj2, obj3, obj4]:
              with pytest.raises(valid_exceptions(use_force)):
                  ray.get(ob)
  
          signaler2 = SignalActor.remote()
          obj1 = wait_for.remote([signaler2.wait.remote()])
          obj2 = wait_for.remote([obj1])
          obj3 = wait_for.remote([obj2])
          obj4 = wait_for.remote([obj3])
  
          assert len(ray.wait([obj3], timeout=0.1)[0]) == 0
          ray.cancel(obj3, force=use_force)
          for ob in [obj3, obj4]:
              with pytest.raises(valid_exceptions(use_force)):
                  ray.get(ob)
  
          with pytest.raises(GetTimeoutError):
              ray.get(obj1, timeout=0.1)
  
          with pytest.raises(GetTimeoutError):
              ray.get(obj2, timeout=0.1)
  
          signaler2.send.remote()
          ray.get(obj1)
  
file_path: ray/python/ray/tests/test_client_terminate.py
imports: import sys
  import time
  import pytest
  from ray._private.test_utils import convert_actor_state, wait_for_condition
  from ray.exceptions import GetTimeoutError, ObjectLostError, RayTaskError, TaskCancelledError, WorkerCrashedError
  from ray.tests.client_test_utils import create_remote_signal_actor
  from ray.util.client.ray_client_helpers import ray_start_client_server
label_desc: Use image node_id 4 for calling a global function with example usage: test_cancel_chain(ray_start_regular, use_force) and returns: ray