code: def test_cancelled_reschedule_worker_state(ws_with_running_task):
      """Same as test_cancelled_reschedule"""
      ws = ws_with_running_task
  
      instructions = ws.handle_stimulus(
          FreeKeysEvent(keys=["x"], stimulus_id="s1")
      )
      assert not instructions
      assert ws.tasks["x"].state == "cancelled"
      assert ws.available_resources == {"R": 0}
  
      instructions = ws.handle_stimulus(
          RescheduleEvent(key="x", stimulus_id="s2")
      )
      assert not instructions  # There's no RescheduleMsg
      assert not ws.tasks  # The task has been forgotten
      assert ws.available_resources == {"R": 1}
  
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 1 for calling a global function with example usage: test_cancelled_reschedule_worker_state(ws_with_running_task) without return types