code: def test_as_completed(executor) -> None:
      def f(x: float) -> float:
          time.sleep(x)
          return x
  
      # slow need to be > 1.5s otherwise it might finish before we start polling.
      slow, fast = 1.5, 0.1
      # One slow job and two fast jobs.
      jobs = executor.map_array(f, [slow, fast, fast])
      start = time.time()
      finished_jobs = []
      for n, j in enumerate(
          helpers.as_completed(jobs, poll_frequency=0.1)
      ):
          elapsed = time.time() - start
          if n < 2:
              # we start getting result before the slow job finished.
              assert elapsed < slow
          finished_jobs.append(j)
      # We get fast job results first, then result of the slow job.
      assert [fast, fast, slow] == [j.result() for j in finished_jobs]
      assert jobs[0] is finished_jobs[-1]
  
imports: import os
  import time
  import typing
  from pathlib import Path
  import pytest
  from .None import helpers
  from .core import core, utils
label_desc: Use image node_id 3 for calling a global function with example usage: test_as_completed(executor) and returns: x