code: def test_WorkerState__to_dict(ws):
      ws.handle_stimulus(
          AcquireReplicasEvent(
              who_has={"x": ["127.0.0.1:1235"]},
              nbytes={"x": 123},
              stimulus_id="s1",
          )
      )
      ws.handle_stimulus(
          UpdateDataEvent(data={"y": object()}, stimulus_id="s2")
      )
  
      actual = recursive_to_dict(ws)
      # Remove timestamps
      for ev in actual["log"]:
          del ev[-1]
      for stim in actual["stimulus_log"]:
          del stim["handled"]
  
      expect = {
          "address": "127.0.0.1:1",
          "busy_workers": [],
          "constrained": [],
          "data": {"y": None},
          "data_needed": {},
          "executing": [],
          "has_what": {"127.0.0.1:1235": ["x"]},
          "in_flight_tasks": ["x"],
          "in_flight_workers": {"127.0.0.1:1235": ["x"]},
          "log": [
              ["x", "ensure-task-exists", "released", "s1"],
              ["x", "released", "fetch", "fetch", {}, "s1"],
              ["gather-dependencies", "127.0.0.1:1235", ["x"], "s1"],
              ["x", "fetch", "flight", "flight", {}, "s1"],
              ["y", "receive-from-scatter", "released", "s2"],
              ["y", "put-in-memory", "s2"],
              ["y", "released", "memory", "memory", {}, "s2"],
          ],
          "long_running": [],
          "missing_dep_flight": [],
          "nthreads": 1,
          "ready": [],
          "running": True,
          "stimulus_log": [
              {
                  "cls": "AcquireReplicasEvent",
                  "stimulus_id": "s1",
                  "who_has": {"x": ["127.0.0.1:1235"]},
                  "nbytes": {"x": 123},
              },
              {
                  "cls": "UpdateDataEvent",
                  "data": {"y": None},
                  "stimulus_id": "s2",
              },
          ],
          "tasks": {
              "x": {
                  "coming_from": "127.0.0.1:1235",
                  "key": "x",
                  "run_id": -1,
                  "nbytes": 123,
                  "priority": [1],
                  "state": "flight",
                  "who_has": ["127.0.0.1:1235"],
              },
              "y": {
                  "key": "y",
                  "run_id": -1,
                  "nbytes": sizeof(object()),
                  "state": "memory",
              },
          },
          "task_counts": {"['x', 'flight']": 1, "['y', 'memory']": 1},
          "task_cumulative_elapsed": {
              "['x', 'flight']": "SNIP",
              "['y', 'memory']": "SNIP",
          },
          "transition_counter": 3,
      }
  
      # timings data (a few microseconds each)
      for k in actual["task_cumulative_elapsed"]:
          actual["task_cumulative_elapsed"][k] = "SNIP"
  
      assert actual == expect
  
imports: from __future__ import annotations
  import asyncio
  import gc
  import pickle
  import sys
  from collections import defaultdict
  from collections.abc import Iterator
  from time import sleep
  import pytest
  from tlz import first
  from dask.sizeof import sizeof
  import distributed.profile
  from distributed import Nanny, Worker, wait
  from distributed.compatibility import MACOS, WINDOWS
  from distributed.protocol.serialize import Serialize
  from distributed.scheduler import TaskState
  from distributed.utils import recursive_to_dict
  from distributed.utils_test import NO_AMM, _LockedCommPool, assert_story, async_poll_for, freeze_data_fetching, gen_cluster, inc, wait_for_state
  from distributed.worker_state_machine import AcquireReplicasEvent, AddKeysMsg, ComputeTaskEvent, Execute, ExecuteFailureEvent, ExecuteSuccessEvent, FreeKeysEvent, GatherDep, GatherDepBusyEvent, GatherDepFailureEvent, GatherDepNetworkFailureEvent, GatherDepSuccessEvent, Instruction, InvalidTaskState, InvalidTransition, PauseEvent, RecommendationsConflict, RefreshWhoHasEvent, ReleaseWorkerDataMsg, RemoveReplicasEvent, RemoveWorkerEvent, RequestRefreshWhoHasMsg, RescheduleEvent, RescheduleMsg, RetryBusyWorkerEvent, RetryBusyWorkerLater, SecedeEvent, StateMachineEvent, TaskErredMsg, TaskState, TransitionCounterMaxExceeded, UnpauseEvent, UpdateDataEvent, merge_recs_instructions
label_desc: Use image node_id 7 for calling a global function with example usage: test_WorkerState__to_dict(ws) without return types