old_contents: import numpy as np
  
  def pad_sequences(seqs, maxlen=None, dtype='int32'):
      """
          Pad each sequence to the same lenght: 
          the lenght of the longuest sequence.
  
          If maxlen is provided, any sequence longer
          than maxlen is truncated to maxlen.
      """
      lengths = [len(s) for s in seqs]
  
      nb_samples = len(seqs)
      if maxlen is None:
          maxlen = np.max(lengths)
  
      x = np.zeros((nb_samples, maxlen)).astype(dtype)
      for idx, s in enumerate(seqs):
          x[idx, :lengths[idx]] = s[:maxlen]
  
      return x
new_contents: import numpy as np
  import random
  
  def pad_sequences(seqs, maxlen=None, dtype='int32'):
      """
          Pad each sequence to the same lenght: 
          the lenght of the longuest sequence.
  
          If maxlen is provided, any sequence longer
          than maxlen is truncated to maxlen.
      """
      lengths = [len(s) for s in seqs]
  
      nb_samples = len(seqs)
      if maxlen is None:
          maxlen = np.max(lengths)
  
      x = np.zeros((nb_samples, maxlen)).astype(dtype)
      for idx, s in enumerate(seqs):
          x[idx, :lengths[idx]] = s[:maxlen]
  
      return x
  
  
  def skipgrams(sequence, vocabulary_size, 
      window_size=4, negative_samples=1., shuffle=True, categorical=False, seed=None):
      ''' 
          Take a sequence (list of indexes of words), 
          returns couples of [word_index, other_word index] and labels (1s or 0s),
          where label = 1 if 'other_word' belongs to the context of 'word',
          and label=0 if 'other_word' is ramdomly sampled
  
          @param vocabulary_size: int. maximum possible word index + 1
          @param window_size: int. actually half-window. The window of a word wi will be [i-window_size, i+window_size+1]
          @param negative_samples: float >= 0. 0 for no negative (=random) samples. 1 for same number as positive samples. etc.
          @param categorical: bool. if False, labels will be integers (eg. [0, 1, 1 .. ]), 
              if True labels will be categorical eg. [[1,0],[0,1],[0,1] .. ]
  
          Note: by convention, index 0 in the vocabulary is a non-word and will be skipped.
      '''
      couples = []
      labels = []
      for i, wi in enumerate(sequence):
          if not wi:
              pass
          window_start = max(0, i-window_size)
          window_end = min(len(sequence), i+window_size+1)
          for j in range(window_start, window_end):
              if j != i:
                  wj = sequence[j]
                  if not wj:
                      pass
                  couples.append([wi, wj])
                  if categorical:
                      labels.append([0,1])
                  else:
                      labels.append(1)
  
      if negative_samples > 0:
          nb_negative_samples = int(len(labels) * negative_samples)
          words = [c[0] for c in couples]
          random.shuffle(words)
          
          couples += [[words[i%len(words)], random.randint(1, vocabulary_size-1)] for i in range(nb_negative_samples)]
          if categorical:
              labels += [[1,0]]*nb_negative_samples
          else:
              labels += [0]*nb_negative_samples
  
      if shuffle:
          if not seed:
              seed = random.randint(0,10e6)
          random.seed(seed)
          random.shuffle(couples)
          random.seed(seed)
          random.shuffle(labels)
  
      return couples, labels
  
subject: Add skipgram utils to preprocessing.sequence