code: def run_auto3dseg_before_bundlegen(test_path, work_dir):
      """
      Run the Auto3DSeg modules before the BundleGen step.
      Args:
          test_path: a path to contain `sim_dataroot` which is for the simulated dataset file.
          work_dir: working directory
  
      Returns:
          Paths of the outputs from the previous steps
      """
  
      if not os.path.isdir(work_dir):
          os.makedirs(work_dir)
  
      # write to a json file
      dataroot_dir = os.path.join(test_path, "sim_dataroot")
      datalist_file = os.path.join(work_dir, "sim_datalist.json")
      ConfigParser.export_config_file(sim_datalist, datalist_file)
      create_sim_data(
          dataroot_dir,
          sim_datalist,
          (24, 24, 24),
          rad_max=10,
          rad_min=1,
          num_seg_classes=1,
      )
  
      datastats_file = os.path.join(work_dir, "datastats.yaml")
      analyser = DataAnalyzer(
          datalist_file,
          dataroot_dir,
          output_path=os.path.join(work_dir, "datastats.yaml"),
      )
      analyser.get_all_case_stats()
  
      return dataroot_dir, datalist_file, datastats_file
  
imports: from __future__ import annotations
  import os
  import shutil
  import sys
  import tempfile
  import unittest
  import nibabel
  import numpy
  import torch
  from monai.apps.auto3dseg import BundleGen, DataAnalyzer
  from monai.apps.auto3dseg.utils import export_bundle_algo_history, import_bundle_algo_history
  from monai.bundle.config_parser import ConfigParser
  from monai.data import create_test_image_3d
  from monai.utils import set_determinism
  from tests.utils import SkipIfBeforePyTorchVersion, get_testing_algo_template_path, skip_if_downloading_fails, skip_if_no_cuda, skip_if_quick
label_desc: Use image node_id 2 for calling a global function with example usage: run_auto3dseg_before_bundlegen(test_path, work_dir) and returns: dataroot_dir,  datalist_file,  datastats_file