code: def _starmap_helper(submit, function, iterable, timeout, unordered):
      if timeout is not None:
          timer = getattr(time, "monotonic", time.time)
          end_time = timeout + timer()
  
      futures = [submit(function, *args) for args in iterable]
      if unordered:
          futures = set(futures)
  
      def result(future, timeout=None):
          try:
              try:
                  return future.result(timeout)
              finally:
                  future.cancel()
          finally:
              del future
  
      def result_iterator():
          try:
              if unordered:
                  if timeout is None:
                      iterator = as_completed(futures)
                  else:
                      iterator = as_completed(
                          futures, end_time - timer()
                      )
                  for future in iterator:
                      futures.remove(future)
                      future = [future]
                      yield result(future.pop())
              else:
                  futures.reverse()
                  if timeout is None:
                      while futures:
                          yield result(futures.pop())
                  else:
                      while futures:
                          yield result(
                              futures.pop(), end_time - timer()
                          )
          finally:
              while futures:
                  futures.pop().cancel()
  
      return result_iterator()
  
imports: import sys
  import time
  import functools
  import itertools
  import threading
  from ._base import Future
  from ._base import Executor
  from ._base import as_completed
  from .None import _core
label_desc: Use image node_id 1 for calling a global function with example usage: _starmap_helper(submit, function, iterable, timeout, unordered) and returns: result_iterator, future