code: def test_watch():
      stop_called = threading.Event()
      watch_thread = None
      start = time()
  
      def stop():
          if not stop_called.is_set():  # Run setup code
              nonlocal watch_thread
              nonlocal start
              watch_thread = threading.current_thread()
              start = time()
              stop_called.set()
          return time() > start + 0.500
  
      try:
          log = watch(interval="10ms", cycle="50ms", stop=stop)
  
          stop_called.wait(2)
          sleep(0.5)
          assert 1 < len(log) < 10
      finally:
          stop_called.wait()
          watch_thread.join()
  
imports: from __future__ import annotations
  import dataclasses
  import sys
  import threading
  from collections.abc import Iterator, Sequence
  from time import sleep
  import pytest
  from tlz import first
  from distributed.compatibility import WINDOWS
  from distributed.metrics import time
  from distributed.profile import call_stack, create, identifier, info_frame, ll_get_stack, llprocess, lock, merge, plot_data, process, watch
label_desc: Use image node_id 7 for calling a global function with example usage: test_watch() and returns: unknown