code: def main():
      import argparse
      import shutil
      from pathlib import Path
  
      from monailabel.utils.others.generic import device_list, file_ext
  
      os.putenv("MASTER_ADDR", "127.0.0.1")
      os.putenv("MASTER_PORT", "1234")
  
      logging.basicConfig(
          level=logging.INFO,
          format="[%(asctime)s] [%(process)s] [%(threadName)s] [%(levelname)s] (%(name)s:%(lineno)d) - %(message)s",
          datefmt="%Y-%m-%d %H:%M:%S",
          force=True,
      )
  
      home = str(Path.home())
      studies = f"{home}/Datasets/Radiology"
  
      parser = argparse.ArgumentParser()
      parser.add_argument("-s", "--studies", default=studies)
      parser.add_argument(
          "-m", "--model", default="wholeBody_ct_segmentation"
      )
      parser.add_argument(
          "-t",
          "--test",
          default="infer",
          choices=("train", "infer", "batch_infer"),
      )
      args = parser.parse_args()
  
      app_dir = os.path.dirname(__file__)
      studies = args.studies
      conf = {
          "models": args.model,
          "preload": "false",
      }
  
      app = MyApp(app_dir, studies, conf)
  
      # Infer
      if args.test == "infer":
          sample = app.next_sample(request={"strategy": "first"})
          image_id = sample["id"]
          image_path = sample["path"]
  
          # Run on all devices
          for device in device_list():
              res = app.infer(
                  request={
                      "model": args.model,
                      "image": image_id,
                      "device": device,
                  }
              )
              label = res["file"]
              label_json = res["params"]
              test_dir = os.path.join(args.studies, "test_labels")
              os.makedirs(test_dir, exist_ok=True)
  
              label_file = os.path.join(
                  test_dir, image_id + file_ext(image_path)
              )
              shutil.move(label, label_file)
  
              print(label_json)
              print(f"++++ Image File: {image_path}")
              print(f"++++ Label File: {label_file}")
              break
          return
  
      # Batch Infer
      if args.test == "batch_infer":
          app.batch_infer(
              request={
                  "model": args.model,
                  "multi_gpu": False,
                  "save_label": True,
                  "label_tag": "original",
                  "max_workers": 1,
                  "max_batch_size": 0,
              }
          )
          return
  
      # Train
      app.train(
          request={
              "model": args.model,
              "max_epochs": 10,
              "dataset": "Dataset",  # PersistentDataset, CacheDataset
              "train_batch_size": 1,
              "val_batch_size": 1,
              "multi_gpu": False,
              "val_split": 0.1,
          },
      )
  
imports: import logging
  import os
  from typing import Dict
  from monai.transforms import Invertd, SaveImaged
  import monailabel
  from monailabel.interfaces.app import MONAILabelApp
  from monailabel.interfaces.tasks.infer_v2 import InferTask
  from monailabel.interfaces.tasks.scoring import ScoringMethod
  from monailabel.interfaces.tasks.strategy import Strategy
  from monailabel.interfaces.tasks.train import TrainTask
  from monailabel.tasks.activelearning.first import First
  from monailabel.tasks.activelearning.random import Random
  from monailabel.tasks.infer.bundle import BundleInferTask
  from monailabel.tasks.scoring.epistemic_v2 import EpistemicScoring
  from monailabel.tasks.train.bundle import BundleTrainTask
  from monailabel.utils.others.generic import get_bundle_models, strtobool
label_desc: Use image node_id 1 for calling a global function with example usage: main() without return types