class_docstr: Corpus serialized using the `sparse coordinate Matrix Market format
  <https://math.nist.gov/MatrixMarket/formats.html>`_.
  
  Wrap a term-document matrix on disk (in matrix-market format), and present it
  as an object which supports iteration over the matrix rows (~documents).
  
  Notes
  -----
  The file is read into memory one document at a time, not the whole matrix at once,
  unlike e.g. `scipy.io.mmread` and other implementations. This allows you to **process corpora which are larger
  than the available RAM**, in a streamed manner.
  
  Example
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.corpora.mmcorpus import MmCorpus
      >>> from gensim.test.utils import datapath
      >>>
      >>> corpus = MmCorpus(datapath('test_mmcorpus_with_index.mm'))
      >>> for document in corpus:
      ...     pass
docstr: Save a corpus to disk in the sparse coordinate Matrix Market format.
  
  Parameters
  ----------
  fname : str
      Path to file.
  corpus : iterable of list of (int, number)
      Corpus in Bow format.
  id2word : dict of (int, str), optional
      Mapping between word_id -> word. Used to retrieve the total vocabulary size if provided.
      Otherwise, the total vocabulary size is estimated based on the highest feature id encountered in `corpus`.
  progress_cnt : int, optional
      How often to report (log) progress.
  metadata : bool, optional
      Writes out additional metadata?
  
  Warnings
  --------
  This function is automatically called by :class:`~gensim.corpora.mmcorpus.MmCorpus.serialize`, don't
  call it directly, call :class:`~gensim.corpora.mmcorpus.MmCorpus.serialize` instead.
  
  Example
  -------
  .. sourcecode:: pycon
  
      >>> from gensim.corpora.mmcorpus import MmCorpus
      >>> from gensim.test.utils import datapath
      >>>
      >>> corpus = MmCorpus(datapath('test_mmcorpus_with_index.mm'))
      >>>
      >>> MmCorpus.save_corpus("random", corpus)  # Do not do it, use `serialize` instead.
      [97, 121, 169, 201, 225, 249, 258, 276, 303]
code: def save_corpus(
      fname, corpus, id2word=None, progress_cnt=1000, metadata=False
  ):
      """Save a corpus to disk in the sparse coordinate Matrix Market format.
  
      Parameters
      ----------
      fname : str
          Path to file.
      corpus : iterable of list of (int, number)
          Corpus in Bow format.
      id2word : dict of (int, str), optional
          Mapping between word_id -> word. Used to retrieve the total vocabulary size if provided.
          Otherwise, the total vocabulary size is estimated based on the highest feature id encountered in `corpus`.
      progress_cnt : int, optional
          How often to report (log) progress.
      metadata : bool, optional
          Writes out additional metadata?
  
      Warnings
      --------
      This function is automatically called by :class:`~gensim.corpora.mmcorpus.MmCorpus.serialize`, don't
      call it directly, call :class:`~gensim.corpora.mmcorpus.MmCorpus.serialize` instead.
  
      Example
      -------
      .. sourcecode:: pycon
  
          >>> from gensim.corpora.mmcorpus import MmCorpus
          >>> from gensim.test.utils import datapath
          >>>
          >>> corpus = MmCorpus(datapath('test_mmcorpus_with_index.mm'))
          >>>
          >>> MmCorpus.save_corpus("random", corpus)  # Do not do it, use `serialize` instead.
          [97, 121, 169, 201, 225, 249, 258, 276, 303]
  
      """
      logger.info("storing corpus in Matrix Market format to %s", fname)
      num_terms = len(id2word) if id2word is not None else None
      return matutils.MmWriter.write_corpus(
          fname,
          corpus,
          num_terms=num_terms,
          index=True,
          progress_cnt=progress_cnt,
          metadata=metadata,
      )
  
file_path: gensim/gensim/corpora/mmcorpus.py
imports: import logging
  from gensim import matutils
  from gensim.corpora import IndexedCorpus
label_desc: Use image node_id 3 for calling the MmCorpus obj's underlying member method code with example usage: obj.save_corpus(fname, corpus, id2word, progress_cnt, metadata) and returns: matutils