code: def from_binary(
              cls,
              fname,
              vocab_unicode_size=78,
              desired_vocab=None,
              encoding="utf-8",
              new_lines=True,
      ):
          
          with open(fname, "rb") as fin:
              # The first line has the vocab_size and the vector_size as text
              header = fin.readline()
              vocab_size, vector_size = list(map(int, header.split()))
  
              vocab = np.empty(vocab_size, dtype="<U%s" % vocab_unicode_size)
              vectors = np.empty((vocab_size, vector_size), dtype=np.float)
              binary_len = np.dtype(np.float32).itemsize * vector_size
              for i in range(vocab_size):
                  # read word
                  word = b""
                  while True:
                      ch = fin.read(1)
                      if ch == b" ":
                          break
                      word += ch
                  include = desired_vocab is None or word in desired_vocab
                  if include:
                      vocab[i] = word.decode(encoding)
  
                  # read vector
                  vector = np.fromstring(fin.read(binary_len), dtype=np.float32)
                  if include:
                      vectors[i] = unitvec(vector)
                  if new_lines:
                      fin.read(1)    # newline char
  
              if desired_vocab is not None:
                  vectors = vectors[vocab != "", :]
                  vocab = vocab[vocab != ""]
          return cls(vocab=vocab, vectors=vectors)
docs: Create a WordVectors class based on a word2vec binary file
  
          Parameters
          ----------
          fname : path to file
          vocabUnicodeSize: the maximum string length (78, by default)
          desired_vocab: if set any words that don't fall into this vocab will be droped
  
          Returns
          -------
          WordVectors instance