code: def shingles(input, size=2):
      d = defaultdict(int)
      for shingle in (
          input[i : i + size] for i in xrange(len(input) - (size - 1))
      ):
          d[shingle] += 1
      return iteritems(d)
  
imports: from __future__ import division
  import random
  from collections import defaultdict
  from math import log
  from whoosh.compat import xrange, iteritems
label_desc: Use image node_id 1 for calling a global function with example usage: shingles(input, size) and returns: iteritems