def load_with_vocab(fin, vocab, dtype=np.float32):
line = next(fin)<EOL>data = line.strip().split(b'<STR_LIT:U+0020>')<EOL>assert len(data) == <NUM_LIT:2><EOL>size = int(data[<NUM_LIT:1>])<EOL>arr = np.empty((len(vocab), size), dtype=dtype)<EOL>arr.fill(np.NaN)<EOL>for line in fin:<EOL><INDENT>token, v = _load_line(line, dtype, size)<EOL>if token in vocab:<EOL><INDENT>arr[vocab[token], :] = v<EOL><DEDENT><DEDENT>if np.any(np.isnan(arr)):<EOL><INDENT>raise ParseError(b"<STR_LIT>")<EOL><DEDENT>return arr<EOL>
Refer to :func:`word_embedding_loader.loader.glove.load_with_vocab` for the API.