code: def test_cancel_stress_sync(loop):
      da = pytest.importorskip("dask.array")
      x = da.random.random((50, 50), chunks=(2, 2))
      with cluster(active_rpc_timeout=10) as (s, [a, b]):
          with Client(s["address"], loop=loop) as c:
              x = c.persist(x)
              y = (x.sum(axis=0) + x.sum(axis=1) + 1).std()
              wait(x)
              for _ in range(5):
                  f = c.compute(y)
                  sleep(random.random())
                  c.cancel(f)
  
file_path: distributed/distributed/tests/test_stress.py
imports: from __future__ import annotations
  import asyncio
  import random
  from contextlib import suppress
  from operator import add
  from time import sleep
  import pytest
  from tlz import concat, sliding_window
  from dask import delayed
  from distributed import Client, Nanny, Worker, wait
  from distributed.chaos import KillWorker
  from distributed.compatibility import WINDOWS
  from distributed.metrics import time
  from distributed.utils import CancelledError
  from distributed.utils_test import NO_AMM, bump_rlimit, cluster, gen_cluster, inc, nodebug_setup_module, nodebug_teardown_module, slowadd, slowinc, slowsum
label_desc: Use image node_id 2 for calling a global function with example usage: test_cancel_stress_sync(loop) without return types