code: def extract_ranges(index_list, range_size_limit=32):
      
      if not index_list:
          return [], []
      first = index_list[0]
      last = first
      ranges = []
      singles = []
      for i in index_list[1:]:
          if i == last + 1 and (last - first) <= range_size_limit:
              last = i
          else:
              if last > first:
                  ranges.append([first, last])
              else:
                  singles.append(first)
              first = i
              last = i
      if last > first:
          ranges.append([first, last])
      else:
          singles.append(first)
      return ranges, singles
docs: Extract consecutive ranges and singles from index_list.
  
    Args:
      index_list: List of monotone increasing non-negative integers.
      range_size_limit: Largest size range to return.  If a larger
        consecutive range exists it will be returned as multiple
        ranges.
  
    Returns:
     ranges, singles where ranges is a list of [first, last] pairs of
       consecutive elements in index_list, and singles is all of the
       other elements, in original order.