code: def test_as_completed_add(client):
      total = 0
      expected = sum(map(inc, range(10)))
      futures = client.map(inc, range(10))
      ac = as_completed(futures)
      for future in ac:
          result = future.result()
          total += result
          if random.random() < 0.5:
              future = client.submit(add, future, 10)
              ac.add(future)
              expected += result + 10
      assert total == expected
  
imports: from __future__ import annotations
  import asyncio
  import queue
  import random
  from collections.abc import Iterator
  from operator import add
  from time import sleep
  import pytest
  from distributed import TimeoutError
  from distributed.client import _as_completed, _first_completed, as_completed, wait
  from distributed.metrics import time
  from distributed.utils import CancelledError
  from distributed.utils_test import gen_cluster, inc, slowinc, throws
label_desc: Use image node_id 4 for calling a global function with example usage: test_as_completed_add(client) without return types