class_docstr: Corpus in SVMlight format.
  
  Quoting http://svmlight.joachims.org/:
  The input file contains the training examples. The first lines  may contain comments and are ignored
  if they start with #. Each of the following lines represents one training example
  and is of the following format::
  
      <line> .=. <target> <feature>:<value> <feature>:<value> ... <feature>:<value> # <info>
      <target> .=. +1 | -1 | 0 | <float>
      <feature> .=. <integer> | "qid"
      <value> .=. <float>
      <info> .=. <string>
  
  The "qid" feature (used for SVMlight ranking), if present, is ignored.
  
  Notes
  -----
  Although not mentioned in the specification above, SVMlight also expect its feature ids to be 1-based
  (counting starts at 1). We convert features to 0-base internally by decrementing all ids when loading a SVMlight
  input file, and increment them again when saving as SVMlight.
class_docstr_tok: ["Corpus","in","SVMlight","format",".","Quoting","http",":","\/\/svmlight.joachims.org\/",":","The","input","file","contains","the","training","examples",".","The","first","lines","may","contain","comments","and","are","ignored","if","they","start","with","#",".","Each","of","the","following","lines","represents","one","training","example","and","is","of","the","following","format",":",":","<","line",">",".=",".","<","target",">","<","feature",">",":","<","value",">","<","feature",">",":","<","value",">","...","<","feature",">",":","<","value",">","#","<","info",">","<","target",">",".=",".","+1","|","-1","|","0","|","<","float",">","<","feature",">",".=",".","<","integer",">","|","``","qid","''","<","value",">",".=",".","<","float",">","<","info",">",".=",".","<","string",">","The","``","qid","''","feature","(","used","for","SVMlight","ranking",")",",","if","present",",","is","ignored",".","Notes","--","--","-","Although","not","mentioned","in","the","specification","above",",","SVMlight","also","expect","its","feature","ids","to","be","1-based","(","counting","starts","at","1",")",".","We","convert","features","to","0-base","internally","by","decrementing","all","ids","when","loading","a","SVMlight","input","file",",","and","increment","them","again","when","saving","as","SVMlight","."]
docstr: Save a corpus in the SVMlight format.
  
  The SVMlight `<target>` class tag is taken from the `labels` array, or set to 0 for all documents
  if `labels` is not supplied.
  
  Parameters
  ----------
  fname : str
      Path to output file.
  corpus : iterable of iterable of (int, float)
      Corpus in BoW format.
  id2word : dict of (str, str), optional
      Mapping id -> word.
  labels : list or False
      An SVMlight `<target>` class tags or False if not present.
  metadata : bool
      ARGUMENT WILL BE IGNORED.
  
  Returns
  -------
  list of int
      Offsets for each line in file (in bytes).
docstr_tok: ["Save","a","corpus","in","the","SVMlight","format",".","The","SVMlight","`","<","target",">","`","class","tag","is","taken","from","the","`","labels","`","array",",","or","set","to","0","for","all","documents","if","`","labels","`","is","not","supplied",".","Parameters","--","--","--","--","--","fname",":","str","Path","to","output","file",".","corpus",":","iterable","of","iterable","of","(","int",",","float",")","Corpus","in","BoW","format",".","id2word",":","dict","of","(","str",",","str",")",",","optional","Mapping","id","-",">","word",".","labels",":","list","or","False","An","SVMlight","`","<","target",">","`","class","tags","or","False","if","not","present",".","metadata",":","bool","ARGUMENT","WILL","BE","IGNORED",".","Returns","--","--","--","-","list","of","int","Offsets","for","each","line","in","file","(","in","bytes",")","."]
code: def save_corpus(
      fname, corpus, id2word=None, labels=False, metadata=False
  ):
      """Save a corpus in the SVMlight format.
  
      The SVMlight `<target>` class tag is taken from the `labels` array, or set to 0 for all documents
      if `labels` is not supplied.
  
      Parameters
      ----------
      fname : str
          Path to output file.
      corpus : iterable of iterable of (int, float)
          Corpus in BoW format.
      id2word : dict of (str, str), optional
          Mapping id -> word.
      labels : list or False
          An SVMlight `<target>` class tags or False if not present.
      metadata : bool
          ARGUMENT WILL BE IGNORED.
  
      Returns
      -------
      list of int
          Offsets for each line in file (in bytes).
  
      """
      logger.info("converting corpus to SVMlight format: %s", fname)
  
      if labels is not False:
          # Cast any sequence (incl. a numpy array) to a list, to simplify the processing below.
          labels = list(labels)
      offsets = []
      with utils.open(fname, "wb") as fout:
          for docno, doc in enumerate(corpus):
              label = (
                  labels[docno] if labels else 0
              )  # target class is 0 by default
              offsets.append(fout.tell())
              fout.write(
                  utils.to_utf8(SvmLightCorpus.doc2line(doc, label))
              )
      return offsets
  
file_path: gensim/gensim/corpora/svmlightcorpus.py
imports: from __future__ import with_statement
  import logging
  from gensim import utils
  from gensim.corpora import IndexedCorpus
label_desc: Use image node_id 3 for calling the SvmLightCorpus obj's underlying member method code with example usage: obj.save_corpus(fname, corpus, id2word, labels, metadata) and returns: offsets