code: def chunks(self, num_chunks=100, chunk_size=2, random_state=np.random):
      
      chunks = -np.ones_like(self.known_label_idx, dtype=int)
      uniq, lookup = np.unique(self.known_labels, return_inverse=True)
      all_inds = [set(np.where(lookup==c)[0]) for c in xrange(len(uniq))]
      idx = 0
      while idx < num_chunks and all_inds:
        if len(all_inds) == 1:
          c = 0
        else:
          c = random_state.randint(0, high=len(all_inds)-1)
        inds = all_inds[c]
        if len(inds) < chunk_size:
          del all_inds[c]
          continue
        ii = random_state.choice(list(inds), chunk_size, replace=False)
        inds.difference_update(ii)
        chunks[ii] = idx
        idx += 1
      if idx < num_chunks:
        raise ValueError('Unable to make %d chunks of %d examples each' %
                         (num_chunks, chunk_size))
      return chunks
docs: the random state object to be passed must be a numpy random seed