class_docstr: Generate algorithms for the NNI to automate hyperparameter tuning. The module has two major interfaces:
  ``__init__`` which prints out how to set up the NNI, and a trialCommand function ``run_algo`` for the NNI library to
  start the trial of the algo. More about trialCommand function can be found in ``trail code`` section in NNI webpage
  https://nni.readthedocs.io/en/latest/tutorials/hpo_quickstart_pytorch/main.html .
  
  Args:
      algo: an Algo object (e.g. BundleAlgo) with defined methods: ``get_output_path`` and train
          and supports saving to and loading from pickle files via ``algo_from_pickle`` and ``algo_to_pickle``.
      params: a set of parameter to override the algo if override is supported by Algo subclass.
  
  Examples::
  
      The experiment will keep generating new folders to save the model checkpoints, scripts, and configs if available.
      ├── algorithm_templates
      │   └── unet
      ├── unet_0
      │   ├── algo_object.pkl
      │   ├── configs
      │   └── scripts
      ├── unet_0_learning_rate_0.01
      │   ├── algo_object.pkl
      │   ├── configs
      │   ├── model_fold0
      │   └── scripts
      └── unet_0_learning_rate_0.1
          ├── algo_object.pkl
          ├── configs
          ├── model_fold0
          └── scripts
  
      .. code-block:: python
          # Bundle Algorithms are already generated by BundleGen in work_dir
          import_bundle_algo_history(work_dir, only_trained=False)
          algo_dict = self.history[0]  # pick the first algorithm
          algo_name = algo_dict[AlgoKeys.ID]
          onealgo = algo_dict[AlgoKeys.ALGO]
          nni_gen = NNIGen(algo=onealgo)
          nni_gen.print_bundle_algo_instruction()
  
  Notes:
      The NNIGen will prepare the algorithms in a folder and suggest a command to replace trialCommand in the experiment
      config. However, NNIGen will not trigger NNI. User needs to write their NNI experiment configs, and then run the
      NNI command manually.
docstr: The python interface for NNI to run.
  
  Args:
      obj_filename: the pickle-exported Algo object.
      output_folder: the root path of the algorithms templates.
      template_path: the algorithm_template. It must contain algo.py in the follow path:
          ``{algorithm_templates_dir}/{network}/scripts/algo.py``
docstr_tok: ["The","python","interface","for","NNI","to","run",".","Args",":","obj_filename",":","the","pickle-exported","Algo","object",".","output_folder",":","the","root","path","of","the","algorithms","templates",".","template_path",":","the","algorithm_template",".","It","must","contain","algo.py","in","the","follow","path",":","``","{","algorithm_templates_dir","}","\/","{","network","}","\/scripts\/algo.py","``"]
code: def run_algo(
      self,
      obj_filename: str,
      output_folder: str = ".",
      template_path: PathLike | None = None,
  ) -> None:
      """
      The python interface for NNI to run.
  
      Args:
          obj_filename: the pickle-exported Algo object.
          output_folder: the root path of the algorithms templates.
          template_path: the algorithm_template. It must contain algo.py in the follow path:
              ``{algorithm_templates_dir}/{network}/scripts/algo.py``
      """
      if not os.path.isfile(obj_filename):
          raise ValueError(f"{obj_filename} is not found")
  
      self.algo, algo_meta_data = algo_from_pickle(
          obj_filename, template_path=template_path
      )
  
      # step 1 sample hyperparams
      params = self.get_hyperparameters()
      # step 2 set the update params for the algo to run in the next trial
      self.update_params(params)
      # step 3 generate the folder to save checkpoints and train
      self.generate(output_folder)
      self.algo.train(self.params)
      # step 4 report validation acc to controller
      acc = self.algo.get_score()
      algo_meta_data = {str(AlgoKeys.SCORE): acc}
  
      algo_to_pickle(
          self.algo,
          template_path=self.algo.template_path,
          **algo_meta_data,
      )
      self.set_score(acc)
  
imports: from __future__ import annotations
  import os
  from abc import abstractmethod
  from copy import deepcopy
  from typing import Any, cast
  from warnings import warn
  from monai.apps.auto3dseg.bundle_gen import BundleAlgo
  from monai.apps.utils import get_logger
  from monai.auto3dseg import Algo, AlgoGen, algo_from_pickle, algo_to_pickle
  from monai.bundle.config_parser import ConfigParser
  from monai.config import PathLike
  from monai.utils import optional_import
  from monai.utils.enums import AlgoKeys
label_desc: Use image node_id 9 for calling the NNIGen obj's underlying member method code with example usage: obj.run_algo(obj_filename, output_folder, template_path) without return types