docstr: Dump an estimator to the filesystem.
  
  Parameters
  ----------
  language : Language
      The required language.
  template : Template
      The required template
  class_name : str
      Change the default class name which will be used in the generated
      output. By default the class name of the passed estimator will be
      used, e.g. `DecisionTreeClassifier`.
  converter : Callable
      Change the default converter of all floating numbers from the model
      data. By default a simple string cast `str(value)` will be used.
  directory : str or Path
      The destination directory.
  to_json : bool (default: False)
      Return the result as JSON string.
  
  Returns
  -------
  The paths to the dumped files.
docstr_tok: ["Dump","an","estimator","to","the","filesystem",".","Parameters","--","--","--","--","--","language",":","Language","The","required","language",".","template",":","Template","The","required","template","class_name",":","str","Change","the","default","class","name","which","will","be","used","in","the","generated","output",".","By","default","the","class","name","of","the","passed","estimator","will","be","used",",","e.g",".","`","DecisionTreeClassifier","`",".","converter",":","Callable","Change","the","default","converter","of","all","floating","numbers","from","the","model","data",".","By","default","a","simple","string","cast","`","str","(","value",")","`","will","be","used",".","directory",":","str","or","Path","The","destination","directory",".","to_json",":","bool","(","default",":","False",")","Return","the","result","as","JSON","string",".","Returns","--","--","--","-","The","paths","to","the","dumped","files","."]
code: def save(
      self,
      language: enum.Language,
      template: enum.Template,
      class_name: str,
      converter: Callable[[object], str],
      directory: Optional[Union[str, Path]] = None,
      to_json: bool = False,
  ) -> Union[str, Tuple[str, str]]:
      """
      Dump an estimator to the filesystem.
  
      Parameters
      ----------
      language : Language
          The required language.
      template : Template
          The required template
      class_name : str
          Change the default class name which will be used in the generated
          output. By default the class name of the passed estimator will be
          used, e.g. `DecisionTreeClassifier`.
      converter : Callable
          Change the default converter of all floating numbers from the model
          data. By default a simple string cast `str(value)` will be used.
      directory : str or Path
          The destination directory.
      to_json : bool (default: False)
          Return the result as JSON string.
  
      Returns
      -------
      The paths to the dumped files.
      """
  
      if not directory:
          directory = Path(getcwd()).resolve()
      if isinstance(directory, str):
          directory = Path(directory)
      if not directory.is_dir():
          directory = directory.parent
  
      # Port/Transpile estimator:
      ported = self.port(
          language=language,
          template=template,
          class_name=class_name,
          converter=converter,
          to_json=to_json,
      )
      if not isinstance(ported, tuple):
          ported = (ported,)
  
      # Dump ported estimator:
      suffix = language.value.SUFFIX
      filename = class_name + "." + suffix
      filepath = directory / filename
      filepath.write_text(ported[0], encoding="utf-8")
      while not filepath.exists():
          sleep(0.01)
      paths = str(filepath)
  
      # Dump model data:
      if template == enum.Template.EXPORTED and len(ported) == 2:
          json_path = directory / (class_name + ".json")
          json_path.write_text(ported[1], encoding="utf-8")
          while not json_path.exists():
              sleep(0.01)
          paths = (paths, str(json_path))
  
      return paths
  
file_path: sklearn-porter/sklearn_porter/estimator/EstimatorBase.py
imports: from os import environ, getcwd
  from pathlib import Path
  from time import sleep
  from typing import Dict, Optional, Set, Tuple, Union, Callable
  from jinja2 import DictLoader, Environment
  from loguru import logger
  from sklearn import __version__
  from sklearn.base import BaseEstimator
  from sklearn_porter import __version__
  from sklearn_porter import enums
  from sklearn_porter.estimator.EstimatorApiABC import EstimatorApiABC
label_desc: Use image node_id 3 for calling the EstimatorBase obj's underlying member method code with example usage: obj.save(language, template, class_name, converter, directory, to_json) and returns: paths