code: def swin(data, size):
      clusters = []
      for i, left in enumerate(data):
          j = i
          right = data[j]
          while j < len(data) - 1 and right - left < size:
              j += 1
              right = data[j]
          v = 99999
          if j - i > 1:
              v = two_pass_variance(data[i : j + 1])
          clusters.append((left, right, j - i, v))
      clusters.sort(key=lambda x: (0 - x[2], x[3]))
      return clusters
  
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 8 for calling a global function with example usage: swin(data, size) and returns: clusters