code: def test_train():
      with TemporaryDirectory() as path:
          # generate training dataset
          for n_channels in [1, 2]:
              TRAIN_CONFIG["n_channels"] = n_channels
              generate_fake_training_dataset(
                  path,
                  n_channels=n_channels,
                  fs=TRAIN_CONFIG["sample_rate"],
              )
              # set training command arguments
              runner = CliRunner()
  
              model_dir = join(path, f"model_{n_channels}")
              train_dir = join(path, "train")
              cache_dir = join(path, f"cache_{n_channels}")
  
              TRAIN_CONFIG["train_csv"] = join(train_dir, "train.csv")
              TRAIN_CONFIG["validation_csv"] = join(
                  train_dir, "train.csv"
              )
              TRAIN_CONFIG["model_dir"] = model_dir
              TRAIN_CONFIG["training_cache"] = join(
                  cache_dir, "training"
              )
              TRAIN_CONFIG["validation_cache"] = join(
                  cache_dir, "validation"
              )
              with open("useless_config.json", "w") as stream:
                  json.dump(TRAIN_CONFIG, stream)
  
              # execute training
              result = runner.invoke(
                  spleeter,
                  [
                      "train",
                      "-p",
                      "useless_config.json",
                      "-d",
                      path,
                      "--verbose",
                  ],
              )
  
              # assert that model checkpoint was created.
              assert os.path.exists(
                  join(model_dir, "model.ckpt-10.index")
              )
              assert os.path.exists(join(model_dir, "checkpoint"))
              assert os.path.exists(
                  join(model_dir, "model.ckpt-0.meta")
              )
              assert result.exit_code == 0
  
file_path: spleeter/tests/test_train.py
imports: import json
  import os
  from os import makedirs
  from os.path import join
  from tempfile import TemporaryDirectory
  import numpy
  import pandas
  from typer.testing import CliRunner
  from spleeter.__main__ import spleeter
  from spleeter.audio.adapter import AudioAdapter
label_desc: Use image node_id 2 for calling a global function with example usage: test_train() without return types