code: def load_glove(filepath, batch_size=1000, limit=None, verbose=True):
      r
      num_dim = isglove(filepath)
      tqdm_prog = tqdm if verbose else no_tqdm
      wv = KeyedVectors(num_dim)
  
      if limit:
          vocab_size = int(limit)
      else:
          with ensure_open(filepath) as fin:
              for i, line in enumerate(fin):
                  pass
          vocab_size = i + 1
  
      wv.vectors = np.zeros((vocab_size, num_dim), REAL)
  
      with ensure_open(filepath) as fin:
          batch, words = [], []
          for i, line in enumerate(tqdm_prog(fin, total=vocab_size)):
              line = line.split()
              word = line[0]
              vector = np.array(line[1:]).astype(float)
              # words.append(word)
              # batch.append(vector)
              wv.index2word.append(word)
              wv.vocab[word] = Vocab(index=i, count=vocab_size - i)
              wv.vectors[i] = vector
              if len(words) >= batch_size:
                  # wv[words] = np.array(batch)
                  batch, words = [], []
              if i >= vocab_size - 1:
                  break
          if words:
              wv[words] = np.array(batch)
      return wv
docs: r""" Load a pretrained GloVE word vector model
  
      First header line of GloVE text file should look like:
          400000 50\n
      First vector of GloVE text file should look like:
          the .12 .22 .32 .42 ... .42
  
      >>> wv = load_glove(os.path.join(BIGDATA_PATH, 'glove_test.txt'))
      >>> wv.most_similar('and')[:3]
      [(',', 0.92...),
       ('.', 0.91...),
       ('of', 0.86...)]