class_docstr: An interface for handling Auto3Dseg with minimal inputs and understanding of the internal states in Auto3Dseg.
  The users can run the Auto3Dseg with default settings in one line of code. They can also customize the advanced
  features Auto3Dseg in a few additional lines. Examples of customization include
  
      - change cross-validation folds
      - change training/prediction parameters
      - change ensemble methods
      - automatic hyperparameter optimization.
  
  The output of the interface is a directory that contains
  
      - data statistics analysis report
      - algorithm definition files (scripts, configs, pickle objects) and training results (checkpoints, accuracies)
      - the predictions on the testing datasets from the final algorithm ensemble
      - a copy of the input arguments in form of YAML
      - cached intermediate results
  
  Args:
      work_dir: working directory to save the intermediate and final results.
      input: the configuration dictionary or the file path to the configuration in form of YAML.
          The configuration should contain datalist, dataroot, modality, multigpu, and class_names info.
      algos: optionally specify algorithms to use.  If a dictionary, must be in the form
          {"algname": dict(_target_="algname.scripts.algo.AlgnameAlgo", template_path="algname"), ...}
          If a list or a string, defines a subset of names of the algorithms to use, e.g. 'segresnet' or
          ['segresnet', 'dints'] out of the full set of algorithm templates provided by templates_path_or_url.
          Defaults to None, to use all available algorithms.
      analyze: on/off switch to run DataAnalyzer and generate a datastats report. Defaults to None, to automatically
          decide based on cache, and run data analysis only if we have not completed this step yet.
      algo_gen: on/off switch to run AlgoGen and generate templated BundleAlgos. Defaults to None, to automatically
          decide based on cache, and run algorithm folders generation only if we have not completed this step yet.
      train: on/off switch to run training and generate algorithm checkpoints. Defaults to None, to automatically
          decide based on cache, and run training only if we have not completed this step yet.
      hpo: use hyperparameter optimization (HPO) in the training phase. Users can provide a list of
          hyper-parameter and a search will be performed to investigate the algorithm performances.
      hpo_backend: a string that indicates the backend of the HPO. Currently, only NNI Grid-search mode
          is supported
      ensemble: on/off switch to run model ensemble and use the ensemble to predict outputs in testing
          datasets.
      not_use_cache: if the value is True, it will ignore all cached results in data analysis,
          algorithm generation, or training, and start the pipeline from scratch.
      templates_path_or_url: the folder with the algorithm templates or a url. If None provided, the default template
          zip url will be downloaded and extracted into the work_dir.
      allow_skip: a switch passed to BundleGen process which determines if some Algo in the default templates
          can be skipped based on the analysis on the dataset from Auto3DSeg DataAnalyzer.
      mlflow_tracking_uri: a tracking URI for MLflow server which could be local directory or address of the remote
          tracking Server; MLflow runs will be recorded locally in algorithms' model folder if the value is None.
      kwargs: image writing parameters for the ensemble inference. The kwargs format follows the SaveImage
          transform. For more information, check https://docs.monai.io/en/stable/transforms.html#saveimage.
  
  
  Examples:
      - User can use the one-liner to start the Auto3Dseg workflow
  
      .. code-block:: bash
  
          python -m monai.apps.auto3dseg AutoRunner run --input             '{"modality": "ct", "datalist": "dl.json", "dataroot": "/dr", "multigpu": true, "class_names": ["A", "B"]}'
  
      - User can also save the input dictionary as a input YAML file and use the following one-liner
  
      .. code-block:: bash
  
          python -m monai.apps.auto3dseg AutoRunner run --input=./input.yaml
  
      - User can specify work_dir and data source config input and run AutoRunner:
  
      .. code-block:: python
  
          work_dir = "./work_dir"
          input = "path/to/input_yaml"
          runner = AutoRunner(work_dir=work_dir, input=input)
          runner.run()
  
      - User can specify a subset of algorithms to use and run AutoRunner:
  
      .. code-block:: python
  
          work_dir = "./work_dir"
          input = "path/to/input_yaml"
          algos = ["segresnet", "dints"]
          runner = AutoRunner(work_dir=work_dir, input=input, algos=algos)
          runner.run()
  
      - User can specify a local folder with algorithms templates and run AutoRunner:
  
      .. code-block:: python
  
          work_dir = "./work_dir"
          input = "path/to/input_yaml"
          algos = "segresnet"
          templates_path_or_url = "./local_path_to/algorithm_templates"
          runner = AutoRunner(work_dir=work_dir, input=input, algos=algos, templates_path_or_url=templates_path_or_url)
          runner.run()
  
      - User can specify training parameters by:
  
      .. code-block:: python
  
          input = "path/to/input_yaml"
          runner = AutoRunner(input=input)
          train_param = {
              "num_epochs_per_validation": 1,
              "num_images_per_batch": 2,
              "num_epochs": 2,
          }
          runner.set_training_params(params=train_param)  # 2 epochs
          runner.run()
  
      - User can specify the fold number of cross validation
  
      .. code-block:: python
  
          input = "path/to/input_yaml"
          runner = AutoRunner(input=input)
          runner.set_num_fold(n_fold = 2)
          runner.run()
  
      - User can specify the prediction parameters during algo ensemble inference:
  
      .. code-block:: python
  
          input = "path/to/input_yaml"
          pred_params = {
              'files_slices': slice(0,2),
              'mode': "vote",
              'sigmoid': True,
          }
          runner = AutoRunner(input=input)
          runner.set_prediction_params(params=pred_params)
          runner.run()
  
      - User can define a grid search space and use the HPO during training.
  
      .. code-block:: python
  
          input = "path/to/input_yaml"
          runner = AutoRunner(input=input, hpo=True)
          runner.set_nni_search_space({"learning_rate": {"_type": "choice", "_value": [0.0001, 0.001, 0.01, 0.1]}})
          runner.run()
  
  Notes:
      Expected results in the work_dir as below::
  
          work_dir/
          ├── algorithm_templates # bundle algo templates (scripts/configs)
          ├── cache.yaml          # Autorunner will automatically cache results to save time
          ├── datastats.yaml      # datastats of the dataset
          ├── dints_0             # network scripts/configs/checkpoints and pickle object of the algo
          ├── ensemble_output     # the prediction of testing datasets from the ensemble of the algos
          ├── input.yaml          # copy of the input data source configs
          ├── segresnet_0         # network scripts/configs/checkpoints and pickle object of the algo
          ├── segresnet2d_0       # network scripts/configs/checkpoints and pickle object of the algo
          └── swinunetr_0         # network scripts/configs/checkpoints and pickle object of the algo
docstr: Set the search space for NNI parameter search.
  
  Args:
      search_space: hyper parameter search space in the form of dict. For more information, please check
          NNI documentation: https://nni.readthedocs.io/en/v2.2/Tutorial/SearchSpaceSpec.html .
docstr_tok: ["Set","the","search","space","for","NNI","parameter","search",".","Args",":","search_space",":","hyper","parameter","search","space","in","the","form","of","dict",".","For","more","information",",","please","check","NNI","documentation",":","https",":","\/\/nni.readthedocs.io\/en\/v2.2\/Tutorial\/SearchSpaceSpec.html","."]
code: def set_nni_search_space(
      self, search_space: dict[str, Any]
  ) -> AutoRunner:
      """
      Set the search space for NNI parameter search.
  
      Args:
          search_space: hyper parameter search space in the form of dict. For more information, please check
              NNI documentation: https://nni.readthedocs.io/en/v2.2/Tutorial/SearchSpaceSpec.html .
      """
      value_combinations = 1
      for k, v in search_space.items():
          if "_value" not in v:
              raise ValueError(
                  f"{search_space} key {k} value {v} has not _value"
              )
          value_combinations *= len(v["_value"])
  
      self.search_space = search_space
      self.hpo_tasks = value_combinations
  
      return self
  
imports: from __future__ import annotations
  import os
  import shutil
  import warnings
  from copy import deepcopy
  from time import sleep
  from typing import Any, cast
  import torch
  from monai.apps.auto3dseg.bundle_gen import BundleGen
  from monai.apps.auto3dseg.data_analyzer import DataAnalyzer
  from monai.apps.auto3dseg.ensemble_builder import EnsembleRunner
  from monai.apps.auto3dseg.hpo_gen import NNIGen
  from monai.apps.auto3dseg.utils import export_bundle_algo_history, import_bundle_algo_history
  from monai.apps.utils import get_logger
  from monai.auto3dseg.utils import algo_to_pickle
  from monai.bundle import ConfigParser
  from monai.transforms import SaveImage
  from monai.utils import AlgoKeys, has_option, look_up_option, optional_import
  from monai.utils.misc import check_kwargs_exist_in_class_init, run_cmd
label_desc: Use image node_id 14 for calling the AutoRunner obj's underlying member method code with example usage: obj.set_nni_search_space(search_space) and returns: self