code: def roundrobin(
      *iterables: Iterable[T],
      duplicates: bool = True,
      key: Callable[[T], Hashable] | None = None,
  ) -> Iterator[T]:
      """Performs a round robin iteration of several iterables
  
      Adapted from https://docs.python.org/3/library/itertools.html#recipes
  
      ..code:: python
  
          colours = ["orange", "red", "green"]
          fruits = ["apple", "banana", "orange"]
  
          list(roundrobin(colors, fruits))
          # ["orange", "apple", "red", "banana", "green", "orange"]
  
          list(roundrobin(colors, fruits, duplicates=False))
          # ["orange", "apple", "red", "banana", "green"]
  
      Parameters
      ----------
      *iterables: Iterable[T]
          Any amount of iterables
  
      duplicates: bool = True
          Whether duplicates are allowed
  
      key: Callable[[T], Hashable] | None = None
          A key to use when checking for duplicates
  
      Returns
      -------
      Iterator[T]
          A round robin iterator over the iterables passed
      """
      active_iterators = len(iterables)
      nexts = cycle(
          iter(it).__next__ for it in iterables
      )  # roundrobin workhorse
  
      # We split up the algorithm into removing duplicates and not. This removes the if
      # statement from within the loop at the cost of duplication.
      if duplicates:
          while active_iterators > 0:
              try:
                  for nxt in nexts:
                      yield nxt()
              except StopIteration:
                  active_iterators -= 1
                  nexts = cycle(islice(nexts, active_iterators))
  
      else:
          seen = set()
          key = (
              key if key is not None else lambda x: x
          )  # Identity if None
  
          while active_iterators > 0:
              try:
                  for nxt in nexts:
                      item = nxt()
                      identifier = key(item)
  
                      if identifier not in seen:
                          seen.add(identifier)
                          yield item
  
              except StopIteration:
                  active_iterators -= 1
                  nexts = cycle(islice(nexts, active_iterators))
  
file_path: auto-sklearn/autosklearn/util/functional.py
imports: from __future__ import annotations
  from typing import Callable, Hashable, Iterable, Iterator, TypeVar
  from functools import reduce
  from itertools import chain, cycle, islice, tee
label_desc: Use image node_id 7 for calling a global function with example usage: roundrobin() without return types