code: def test_reschedule_resumed(ws_with_running_task):
      """Test state loop:
  
      executing -> cancelled -> resumed(fetch) -> rescheduled
      executing -> long-running -> cancelled -> resumed(fetch) -> rescheduled
      """
      ws = ws_with_running_task
      ws2 = "127.0.0.1:2"
  
      instructions = ws.handle_stimulus(
          FreeKeysEvent(keys=["x"], stimulus_id="s1"),
          ComputeTaskEvent.dummy(
              "y", who_has={"x": [ws2]}, stimulus_id="s2"
          ),
          RescheduleEvent(key="x", stimulus_id="s3"),
      )
      assert instructions == [
          GatherDep(
              worker=ws2,
              to_gather={"x"},
              total_nbytes=1,
              stimulus_id="s3",
          )
      ]
      assert ws.tasks["x"].state == "flight"
  
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 4 for calling a global function with example usage: test_reschedule_resumed(ws_with_running_task) without return types