class_docstr: Corpus in the UCI bag-of-words format.
docstr: Save a corpus in the UCI Bag-of-Words format.
  
  Warnings
  --------
  This function is automatically called by :meth`gensim.corpora.ucicorpus.UciCorpus.serialize`,
  don't call it directly, call :meth`gensim.corpora.ucicorpus.UciCorpus.serialize` instead.
  
  Parameters
  ----------
  fname : str
      Path to output file.
  corpus: iterable of iterable of (int, int)
      Corpus in BoW format.
  id2word : {dict of (int, str), :class:`gensim.corpora.dictionary.Dictionary`}, optional
      Mapping between words and their ids. If None - will be inferred from `corpus`.
  progress_cnt : int, optional
      Progress counter, write log message each `progress_cnt` documents.
  metadata : bool, optional
      THIS PARAMETER WILL BE IGNORED.
  
  Notes
  -----
  There are actually two files saved: `fname` and `fname.vocab`, where `fname.vocab` is the vocabulary file.
docstr_tok: ["Save","a","corpus","in","the","UCI","Bag-of-Words","format",".","Warnings","--","--","--","--","This","function","is","automatically","called","by",":","meth","`","gensim.corpora.ucicorpus.UciCorpus.serialize","`",",","do","n't","call","it","directly",",","call",":","meth","`","gensim.corpora.ucicorpus.UciCorpus.serialize","`","instead",".","Parameters","--","--","--","--","--","fname",":","str","Path","to","output","file",".","corpus",":","iterable","of","iterable","of","(","int",",","int",")","Corpus","in","BoW","format",".","id2word",":","{","dict","of","(","int",",","str",")",",",":","class",":","`","gensim.corpora.dictionary.Dictionary","`","}",",","optional","Mapping","between","words","and","their","ids",".","If","None","-","will","be","inferred","from","`","corpus","`",".","progress_cnt",":","int",",","optional","Progress","counter",",","write","log","message","each","`","progress_cnt","`","documents",".","metadata",":","bool",",","optional","THIS","PARAMETER","WILL","BE","IGNORED",".","Notes","--","--","-","There","are","actually","two","files","saved",":","`","fname","`","and","`","fname.vocab","`",",","where","`","fname.vocab","`","is","the","vocabulary","file","."]
code: def save_corpus(
      fname, corpus, id2word=None, progress_cnt=10000, metadata=False
  ):
      """Save a corpus in the UCI Bag-of-Words format.
  
      Warnings
      --------
      This function is automatically called by :meth`gensim.corpora.ucicorpus.UciCorpus.serialize`,
      don't call it directly, call :meth`gensim.corpora.ucicorpus.UciCorpus.serialize` instead.
  
      Parameters
      ----------
      fname : str
          Path to output file.
      corpus: iterable of iterable of (int, int)
          Corpus in BoW format.
      id2word : {dict of (int, str), :class:`gensim.corpora.dictionary.Dictionary`}, optional
          Mapping between words and their ids. If None - will be inferred from `corpus`.
      progress_cnt : int, optional
          Progress counter, write log message each `progress_cnt` documents.
      metadata : bool, optional
          THIS PARAMETER WILL BE IGNORED.
  
      Notes
      -----
      There are actually two files saved: `fname` and `fname.vocab`, where `fname.vocab` is the vocabulary file.
  
      """
      if id2word is None:
          logger.info(
              "no word id mapping provided; initializing from corpus"
          )
          id2word = utils.dict_from_corpus(corpus)
          num_terms = len(id2word)
      elif id2word:
          num_terms = 1 + max(id2word)
      else:
          num_terms = 0
  
      # write out vocabulary
      fname_vocab = utils.smart_extension(fname, ".vocab")
      logger.info(
          "saving vocabulary of %i words to %s", num_terms, fname_vocab
      )
      with utils.open(fname_vocab, "wb") as fout:
          for featureid in range(num_terms):
              fout.write(
                  utils.to_utf8("%s\n" % id2word.get(featureid, "---"))
              )
  
      logger.info(
          "storing corpus in UCI Bag-of-Words format: %s", fname
      )
  
      return UciWriter.write_corpus(
          fname, corpus, index=True, progress_cnt=progress_cnt
      )
  
imports: import logging
  from collections import defaultdict
  from gensim import utils
  from gensim.corpora import Dictionary
  from gensim.corpora import IndexedCorpus
  from gensim.matutils import MmReader
  from gensim.matutils import MmWriter
label_desc: Use image node_id 4 for calling the UciCorpus obj's underlying member method code with example usage: obj.save_corpus(fname, corpus, id2word, progress_cnt, metadata) and returns: UciWriter