code: def train_all_datasets():
      # Maps dataset name to current running process.
      max_processes = 4
      running_processes = {}
      accumulated_results = []
      # As each process completes it pushes its results onto the results_queue.
      results_queue = multiprocessing.Queue()
      for dataset_name in datasets.list_datasets():
          if len(running_processes) >= max_processes:
              # Block until a subprocess completes
              next_results = results_queue.get()
              accumulated_results.append(next_results)
              process = running_processes[next_results.dataset_name]
              process.join()
              del running_processes[next_results.dataset_name]
          process = multiprocessing.Process(
              target=_train_dataset_process,
              args=[dataset_name, results_queue],
          )
          running_processes[dataset_name] = process
          process.start()
      while len(running_processes) > 0:
          if len(running_processes) < 4:
              remaining_datasets = ", ".join(
                  sorted(running_processes.keys())
              )
              print(
                  f"Finishing up, waiting for {len(running_processes)} to complete ({remaining_datasets})"
              )
          else:
              print(
                  f"Finishing up, waiting for {len(running_processes)} to complete"
              )
          # Block until a subprocess completes, clear it out,
          next_results = results_queue.get()
          accumulated_results.append(next_results)
          process = running_processes[next_results.dataset_name]
          process.join()
          del running_processes[next_results.dataset_name]
      results_df = pd.DataFrame(accumulated_results)
      with pd.option_context(
          "display.max_rows",
          None,
          "display.max_columns",
          None,
          "display.precision",
          3,
          "display.width",
          120,
      ):
          results_to_display = results_df[
              results_df["has_config"]
          ].copy()
          results_to_display = results_to_display.drop(
              columns=[
                  "dataset_version",
                  "output_directory",
                  "ludwig_version",
                  "ludwig_commit",
                  "has_config",
              ]
          )
          print(results_to_display)
      results_df.to_csv(
          "train_all_model_configs_results.csv", index=False
      )
  
file_path: ludwig/tests/ludwig/datasets/model_configs/train_all_model_configs.py
imports: import multiprocessing
  import time
  from dataclasses import dataclass
  from typing import Optional
  import pandas
  from ludwig import datasets, visualize
  from ludwig.api import LudwigModel
  from ludwig.globals import LUDWIG_VERSION
  from ludwig.utils.misc_utils import get_commit_hash
label_desc: Use image node_id 2 for calling a global function with example usage: train_all_datasets() without return types