class_docstr: An algorithm represented by a set of bundle configurations and scripts.
  
  ``BundleAlgo.cfg`` is a ``monai.bundle.ConfigParser`` instance.
  
  .. code-block:: python
  
      from monai.apps.auto3dseg import BundleAlgo
  
      data_stats_yaml = "../datastats.yaml"
      algo = BundleAlgo(template_path="../algorithm_templates")
      algo.set_data_stats(data_stats_yaml)
      # algo.set_data_src("../data_src.json")
      algo.export_to_disk(".", algo_name="segresnet2d_1")
  
  This class creates MONAI bundles from a directory of 'bundle template'. Different from the regular MONAI bundle
  format, the bundle template may contain placeholders that must be filled using ``fill_template_config`` during
  ``export_to_disk``. Then created bundle keeps the same file structure as the template.
docstr: Execute the training command with target devices information.
docstr_tok: ["Execute","the","training","command","with","target","devices","information","."]
code: def _run_cmd(
      self, cmd: str, devices_info: str = ""
  ) -> subprocess.CompletedProcess:
      """
      Execute the training command with target devices information.
  
      """
      if devices_info:
          warnings.warn(
              f"input devices_info {devices_info} is deprecated and ignored."
          )
  
      ps_environ = os.environ.copy()
      ps_environ["CUDA_VISIBLE_DEVICES"] = str(
          self.device_setting["CUDA_VISIBLE_DEVICES"]
      )
  
      # delete pattern "VAR=VALUE" at the beginning of the string, with optional leading/trailing whitespaces
      cmd = re.sub(r"^\s*\w+=.*?\s+", "", cmd)
  
      if int(self.device_setting["NUM_NODES"]) > 1:
          try:
              look_up_option(
                  self.device_setting["MN_START_METHOD"], ["bcprun"]
              )
          except ValueError as err:
              raise NotImplementedError(
                  f"{self.device_setting['MN_START_METHOD']} is not supported yet."
                  "Try modify BundleAlgo._run_cmd for your cluster."
              ) from err
  
          return _run_cmd_bcprun(
              cmd,
              n=self.device_setting["NUM_NODES"],
              p=self.device_setting["n_devices"],
          )
      elif int(self.device_setting["n_devices"]) > 1:
          return _run_cmd_torchrun(
              cmd,
              nnodes=1,
              nproc_per_node=self.device_setting["n_devices"],
              env=ps_environ,
              check=True,
          )
      else:
          return run_cmd(
              cmd.split(),
              run_cmd_verbose=True,
              env=ps_environ,
              check=True,
          )
  
imports: from __future__ import annotations
  import importlib
  import os
  import re
  import shutil
  import subprocess
  import sys
  import time
  import warnings
  from copy import deepcopy
  from pathlib import Path
  from tempfile import TemporaryDirectory
  from typing import Any
  from urllib.parse import urlparse
  import torch
  from monai.apps import download_and_extract
  from monai.apps.utils import get_logger
  from monai.auto3dseg.algo_gen import Algo, AlgoGen
  from monai.auto3dseg.utils import _prepare_cmd_bcprun, _prepare_cmd_default, _prepare_cmd_torchrun, _run_cmd_bcprun, _run_cmd_torchrun, algo_to_pickle
  from monai.bundle.config_parser import ConfigParser
  from monai.config import PathLike
  from monai.utils import ensure_tuple, look_up_option, run_cmd
  from monai.utils.enums import AlgoKeys
  from monai.utils.misc import MONAIEnvVars
label_desc: Use image node_id 9 for calling the BundleAlgo obj's underlying member method code with example usage: obj._run_cmd(cmd, devices_info) and returns: _run_cmd_bcprun, _run_cmd_torchrun, run_cmd