code: def test_restart_sync(loop):
      with cluster(nanny=True) as (s, [a, b]):
          with Client(s["address"], loop=loop) as c:
              x = c.submit(div, 1, 2)
              x.result()
  
              assert sync(loop, c.scheduler.who_has)
              c.restart()
              assert not sync(loop, c.scheduler.who_has)
              assert x.cancelled()
              assert len(c.nthreads()) == 2
  
              with pytest.raises(CancelledError):
                  x.result()
  
              y = c.submit(div, 1, 3)
              assert y.result() == 1 / 3
  
imports: from __future__ import annotations
  import asyncio
  import os
  import random
  from contextlib import suppress
  from time import sleep
  from unittest import mock
  import pytest
  from tlz import first, merge, partition_all
  import dask.config
  from dask import delayed
  from dask.utils import parse_bytes
  from distributed import Client, Nanny, profile, wait
  from distributed.comm import CommClosedError
  from distributed.compatibility import MACOS
  from distributed.metrics import time
  from distributed.utils import CancelledError, sync
  from distributed.utils_test import NO_AMM, BlockedGatherDep, BlockedGetData, async_poll_for, captured_logger, cluster, div, gen_cluster, inc, slowadd, slowinc
  from distributed.worker_state_machine import FreeKeysEvent
label_desc: Use image node_id 3 for calling a global function with example usage: test_restart_sync(loop) without return types