class_docstr: Writer for writing out FeatureSets as LibSVM/SVMLight files.
  
  Parameters
  ----------
  path : :class:`skll.types.PathOrStr`
      A path to the feature file we would like to create.
      If ``subsets`` is not ``None``, this is assumed to be a string
      containing the path to the directory to write the feature
      files with an additional file extension specifying the file
      type. For example ``/foo/.libsvm``.
  
  feature_set : :class:`skll.data.featureset.FeatureSet`
      The ``FeatureSet`` instance to dump to the output file.
  
  quiet : bool, default=True
      Do not print "Writing..." status message to stderr.
  
  subsets : Optional[Dict[str, List[str]]], default=None
      A mapping from subset names to lists of feature names
      that are included in those sets. If given, a feature
      file will be written for every subset (with the name
      containing the subset name as suffix to ``path``).
      Note, since string- valued features are automatically
      converted into boolean features with names of the form
      ``FEATURE_NAME=STRING_VALUE``, when doing the
      filtering, the portion before the ``=`` is all that's
      used for matching. Therefore, you do not need to
      enumerate all of these boolean feature names in your
      mapping.
  
  logger : Optional[logging.Logger], default=None
      A logger instance to use to log messages instead of creating
      a new one by default.
  
  label_map : Optional[Dict[str, int]], default=None
      A mapping from label strings to integers.
class_docstr_tok: ["Writer","for","writing","out","FeatureSets","as","LibSVM\/SVMLight","files",".","Parameters","--","--","--","--","--","path",":",":","class",":","`","skll.types.PathOrStr","`","A","path","to","the","feature","file","we","would","like","to","create",".","If","``","subsets","``","is","not","``","None","``",",","this","is","assumed","to","be","a","string","containing","the","path","to","the","directory","to","write","the","feature","files","with","an","additional","file","extension","specifying","the","file","type",".","For","example","``","\/foo\/.libsvm","``",".","feature_set",":",":","class",":","`","skll.data.featureset.FeatureSet","`","The","``","FeatureSet","``","instance","to","dump","to","the","output","file",".","quiet",":","bool",",","default=True","Do","not","print","``","Writing","...","''","status","message","to","stderr",".","subsets",":","Optional","[","Dict","[","str",",","List","[","str","]","]","]",",","default=None","A","mapping","from","subset","names","to","lists","of","feature","names","that","are","included","in","those","sets",".","If","given",",","a","feature","file","will","be","written","for","every","subset","(","with","the","name","containing","the","subset","name","as","suffix","to","``","path","``",")",".","Note",",","since","string-","valued","features","are","automatically","converted","into","boolean","features","with","names","of","the","form","``","FEATURE_NAME=STRING_VALUE","``",",","when","doing","the","filtering",",","the","portion","before","the","``","=","``","is","all","that's","used","for","matching",".","Therefore",",","you","do","not","need","to","enumerate","all","of","these","boolean","feature","names","in","your","mapping",".","logger",":","Optional","[","logging.Logger","]",",","default=None","A","logger","instance","to","use","to","log","messages","instead","of","creating","a","new","one","by","default",".","label_map",":","Optional","[","Dict","[","str",",","int","]","]",",","default=None","A","mapping","from","label","strings","to","integers","."]
docstr: Sanitize feature names for older feature formats.
  
  Replace special characters in names with close unicode
  equivalents to make things loadable in by LibSVM, LibLinear, or
  SVMLight.
  
  Parameters
  ----------
  name : Union[:class:`skll.types.IdType`, :class:`skll.types.LabelType`]
      Input name in which special characters are replaced with unicode
      equivalents.
  
  Returns
  -------
  Union[:class:`skll.types.IdType`, :class:`skll.types.LabelType`]
      The sanitized name with special characters replaced.
docstr_tok: ["Sanitize","feature","names","for","older","feature","formats",".","Replace","special","characters","in","names","with","close","unicode","equivalents","to","make","things","loadable","in","by","LibSVM",",","LibLinear",",","or","SVMLight",".","Parameters","--","--","--","--","--","name",":","Union","[",":","class",":","`","skll.types.IdType","`",",",":","class",":","`","skll.types.LabelType","`","]","Input","name","in","which","special","characters","are","replaced","with","unicode","equivalents",".","Returns","--","--","--","-","Union","[",":","class",":","`","skll.types.IdType","`",",",":","class",":","`","skll.types.LabelType","`","]","The","sanitized","name","with","special","characters","replaced","."]
code: def _sanitize(
      name: Union[IdType, LabelType]
  ) -> Union[IdType, LabelType]:
      """
      Sanitize feature names for older feature formats.
  
      Replace special characters in names with close unicode
      equivalents to make things loadable in by LibSVM, LibLinear, or
      SVMLight.
  
      Parameters
      ----------
      name : Union[:class:`skll.types.IdType`, :class:`skll.types.LabelType`]
          Input name in which special characters are replaced with unicode
          equivalents.
  
      Returns
      -------
      Union[:class:`skll.types.IdType`, :class:`skll.types.LabelType`]
          The sanitized name with special characters replaced.
      """
      sanitized_name = name
      if isinstance(sanitized_name, str):
          for (
              orig,
              replacement,
          ) in LibSVMWriter.LIBSVM_REPLACE_DICT.items():
              sanitized_name = sanitized_name.replace(orig, replacement)
      return sanitized_name
  
imports: import json
  import logging
  import sys
  from csv import DictWriter
  from decimal import Decimal
  from pathlib import Path
  from typing import IO, Any, Dict, List, Optional, Set, Tuple, Union
  import numpy
  import pandas
  from scipy.sparse import issparse
  from sklearn.feature_extraction import DictVectorizer, FeatureHasher
  from skll.data import FeatureSet
  from skll.types import FeatGenerator, FeatureDict, IdType, LabelType, PathOrStr
label_desc: Use image node_id 2 for calling the LibSVMWriter obj's underlying member method code with example usage: obj._sanitize(name) and returns: sanitized_name