class_docstr: Initialize the np2vec model, train it, save it and load it.
docstr: Save the np2vec model.
  
  Args:
      np2vec_model_file (str): the file containing the np2vec model to load
      binary (bool): boolean indicating whether the np2vec model to load is in binary format
      word2vec_format(bool): boolean indicating whether to save the model in original
      word2vec format.
docstr_tok: ["Save","the","np2vec","model",".","Args",":","np2vec_model_file","(","str",")",":","the","file","containing","the","np2vec","model","to","load","binary","(","bool",")",":","boolean","indicating","whether","the","np2vec","model","to","load","is","in","binary","format","word2vec_format","(","bool",")",":","boolean","indicating","whether","to","save","the","model","in","original","word2vec","format","."]
code: def save(
      self,
      np2vec_model_file="np2vec.model",
      binary=False,
      word2vec_format=True,
  ):
      """
      Save the np2vec model.
  
      Args:
          np2vec_model_file (str): the file containing the np2vec model to load
          binary (bool): boolean indicating whether the np2vec model to load is in binary format
          word2vec_format(bool): boolean indicating whether to save the model in original
          word2vec format.
      """
      if (
          self.word_embedding_type == "fasttext"
          and self.word_ngrams == 1
      ):
          if not binary:
              logger.error(
                  "if word_embedding_type is fasttext and word_ngrams is 1, "
                  "binary should be set to True."
              )
              sys.exit(0)
          # not relevant to prune fasttext subword model
          self.model.save(np2vec_model_file)
      else:
          # prune non NP terms
          if self.prune_non_np:
              logger.info("pruning np2vec model")
              total_vec = 0
              vector_size = self.model.vector_size
              for word in self.model.wv.vocab.keys():
                  if self.is_marked(word) and len(word) > 1:
                      total_vec += 1
              logger.info(
                  "storing %sx%s projection weights for NP's into %s",
                  total_vec,
                  vector_size,
                  np2vec_model_file,
              )
              with smart_open(np2vec_model_file, "wb") as fout:
                  fout.write(
                      utils.to_utf8(
                          "%s %s\n" % (total_vec, vector_size)
                      )
                  )
                  # store NP vectors in sorted order: most frequent NP's at the top
                  for word, vocab in sorted(
                      iteritems(self.model.wv.vocab),
                      key=lambda item: -item[1].count,
                  ):
                      if (
                          self.is_marked(word) and len(word) > 1
                      ):  # discard empty marked np's
                          embedding_vec = self.model.wv.syn0[
                              vocab.index
                          ]
                          if binary:
                              fout.write(
                                  utils.to_utf8(word)
                                  + b" "
                                  + embedding_vec.tostring()
                              )
                          else:
                              fout.write(
                                  utils.to_utf8(
                                      "%s %s\n"
                                      % (
                                          word,
                                          " ".join(
                                              "%f" % val
                                              for val in embedding_vec
                                          ),
                                      )
                                  )
                              )
              if not word2vec_format:
                  # pylint: disable=attribute-defined-outside-init
                  self.model = KeyedVectors.load_word2vec_format(
                      np2vec_model_file, binary=binary
                  )
          if not word2vec_format:
              self.model.save(np2vec_model_file)
  
file_path: nlp-architect/nlp_architect/models/np2vec.py
imports: import json
  import logging
  import sys
  from gensim.models import FastText, Word2Vec, KeyedVectors
  from gensim.models.word2vec import LineSentence
  from gensim import utils
  import nltk
  from nltk.corpus import conll2000
  from six import iteritems
  from smart_open import open
label_desc: Use image node_id 4 for calling the NP2vec obj's underlying member method code with example usage: obj.save(np2vec_model_file, binary, word2vec_format) without return types