class_docstr: Store a corpus in `Matrix Market format <https://math.nist.gov/MatrixMarket/formats.html>`_,
  using :class:`~gensim.corpora.mmcorpus.MmCorpus`.
  
  Notes
  -----
  The output is written one document at a time, not the whole matrix at once (unlike e.g. `scipy.io.mmread`).
  This allows you to write corpora which are larger than the available RAM.
  
  The output file is created in a single pass through the input corpus, so that the input can be
  a once-only stream (generator).
  
  To achieve this, a fake MM header is written first, corpus statistics are collected
  during the pass (shape of the matrix, number of non-zeroes), followed by a seek back to the beginning of the file,
  rewriting the fake header with the final values.
class_docstr_tok: ["Store","a","corpus","in","`","Matrix","Market","format","<","https",":","\/\/math.nist.gov\/MatrixMarket\/formats.html",">","`","_",",","using",":","class",":","`","~gensim.corpora.mmcorpus.MmCorpus","`",".","Notes","--","--","-","The","output","is","written","one","document","at","a","time",",","not","the","whole","matrix","at","once","(","unlike","e.g",".","`","scipy.io.mmread","`",")",".","This","allows","you","to","write","corpora","which","are","larger","than","the","available","RAM",".","The","output","file","is","created","in","a","single","pass","through","the","input","corpus",",","so","that","the","input","can","be","a","once-only","stream","(","generator",")",".","To","achieve","this",",","a","fake","MM","header","is","written","first",",","corpus","statistics","are","collected","during","the","pass","(","shape","of","the","matrix",",","number","of","non-zeroes",")",",","followed","by","a","seek","back","to","the","beginning","of","the","file",",","rewriting","the","fake","header","with","the","final","values","."]
docstr: Write headers to file.
  
  Parameters
  ----------
  num_docs : int
      Number of documents in corpus.
  num_terms : int
      Number of term in corpus.
  num_nnz : int
      Number of non-zero elements in corpus.
docstr_tok: ["Write","headers","to","file",".","Parameters","--","--","--","--","--","num_docs",":","int","Number","of","documents","in","corpus",".","num_terms",":","int","Number","of","term","in","corpus",".","num_nnz",":","int","Number","of","non-zero","elements","in","corpus","."]
code: def write_headers(self, num_docs, num_terms, num_nnz):
      """Write headers to file.
  
      Parameters
      ----------
      num_docs : int
          Number of documents in corpus.
      num_terms : int
          Number of term in corpus.
      num_nnz : int
          Number of non-zero elements in corpus.
  
      """
      self.fout.write(MmWriter.HEADER_LINE)
  
      if num_nnz < 0:
          # we don't know the matrix shape/density yet, so only log a general line
          logger.info("saving sparse matrix to %s", self.fname)
          self.fout.write(
              utils.to_utf8(" " * 50 + "\n")
          )  # 48 digits must be enough for everybody
      else:
          logger.info(
              "saving sparse %sx%s matrix with %i non-zero entries to %s",
              num_docs,
              num_terms,
              num_nnz,
              self.fname,
          )
          self.fout.write(
              utils.to_utf8(
                  "%s %s %s\n" % (num_docs, num_terms, num_nnz)
              )
          )
      self.last_docno = -1
      self.headers_written = True
  
imports: from __future__ import with_statement
  import logging
  import math
  from gensim import utils
  import numpy
  import scipy.sparse
  from scipy.stats import entropy
  from scipy.linalg import get_blas_funcs, triu
  from scipy.linalg.lapack import get_lapack_funcs
  from scipy.special import psi
label_desc: Use image node_id 2 for calling the MmWriter obj's underlying member method code with example usage: obj.write_headers(num_docs, num_terms, num_nnz) without return types