code: def pairs(itr: Iterable[T]) -> Iterator[tuple[T, T]]:
      """An iterator over pairs of items in the iterator
  
      ..code:: python
  
          # Check if sorted
          if all(a < b for a, b in pairs(items)):
              ...
  
      Parameters
      ----------
      itr : Iterable[T]
          An itr of items
  
      Returns
      -------
      Iterable[tuple[T, T]]
          An itr of sequential pairs of the items
      """
      itr1, itr2 = tee(itr)
  
      # Skip first item
      _ = next(itr2)
  
      # Check there is a second element
      peek = next(itr2, None)
      if peek is None:
          raise ValueError(
              "Can't create a pair from iterable with 1 item"
          )
  
      # Put it back in
      itr2 = chain([peek], itr2)
  
      return iter((a, b) for a, b in zip(itr1, itr2))
  
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 6 for calling a global function with example usage: pairs(itr) and returns: iter