code: def test_reschedule_cancelled(ws_with_running_task):
      """Test state loop:
  
      executing -> cancelled -> rescheduled
      executing -> long-running -> cancelled -> rescheduled
      """
      ws = ws_with_running_task
      instructions = ws.handle_stimulus(
          FreeKeysEvent(keys=["x"], stimulus_id="s1"),
          RescheduleEvent(key="x", stimulus_id="s2"),
      )
      assert not instructions
      assert "x" not in ws.tasks
  
file_path: distributed/distributed/tests/test_reschedule.py
imports: from __future__ import annotations
  import asyncio
  from time import sleep
  import pytest
  from distributed import Event, Reschedule, get_worker, secede, wait
  from distributed.utils_test import captured_logger, gen_cluster, slowinc
  from distributed.worker_state_machine import ComputeTaskEvent, FreeKeysEvent, GatherDep, RescheduleEvent, RescheduleMsg
label_desc: Use image node_id 3 for calling a global function with example usage: test_reschedule_cancelled(ws_with_running_task) without return types