code: def consecutive_pairs(iterable, circular=False):
      """Returns consecutive pairs of items from the given iterable.
  
      When ``circular`` is ``True``, the pair consisting of the last
      and first elements is also returned.
  
      Example:
  
          >>> list(consecutive_pairs(range(5)))
          [(0, 1), (1, 2), (2, 3), (3, 4)]
          >>> list(consecutive_pairs(range(5), circular=True))
          [(0, 1), (1, 2), (2, 3), (3, 4), (4, 0)]
          >>> list(consecutive_pairs([]))
          []
          >>> list(consecutive_pairs([], circular=True))
          []
          >>> list(consecutive_pairs([0]))
          []
          >>> list(consecutive_pairs([0], circular=True))
          [(0, 0)]
      """
      it = iter(iterable)
  
      try:
          prev = next(it)
      except StopIteration:
          return
      first = prev
  
      for item in it:
          yield prev, item
          prev = item
  
      if circular:
          try:
              yield item, first
          except UnboundLocalError:
              yield first, first
  
imports: from contextlib import contextmanager
  from collections.abc import MutableMapping
  from itertools import chain
  from warnings import warn
  import os
  import tempfile
label_desc: Use image node_id 6 for calling a global function with example usage: consecutive_pairs(iterable, circular) without return types