code: def test_as_completed_update(client):
      total = 0
      todo = list(range(10))
      expected = sum(map(inc, todo))
      ac = as_completed([])
      while todo or not ac.is_empty():
          if todo:
              work, todo = todo[:4], todo[4:]
              ac.update(client.map(inc, work))
          batch = ac.next_batch(block=True)
          total += sum(r.result() for r in batch)
      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 5 for calling a global function with example usage: test_as_completed_update(client) without return types