code: def click_train_test(
      set_progress,
      n_clicks,
      modal_close,
      filename,
      target_col,
      feature_cols,
      exog_cols,
      algorithm,
      table,
      train_percentage,
      test_filename,
      file_mode,
  ):
      ctx = dash.callback_context
      modal_is_open = False
      modal_content = ""
      train_metric_table = create_metric_table()
      test_metric_table = create_metric_table()
      figure = create_empty_figure()
      set_progress(("0", "10"))
  
      try:
          if ctx.triggered and n_clicks > 0:
              prop_id = ctx.triggered_id
              if prop_id == "forecasting-train-btn":
                  assert filename, "The training data file is empty!"
                  assert (
                      target_col
                  ), "Please select a target variable/metric for forecasting."
                  assert (
                      algorithm
                  ), "Please select a forecasting algorithm."
                  feature_cols = feature_cols or []
                  exog_cols = exog_cols or []
  
                  df = ForecastModel().load_data(
                      os.path.join(
                          file_manager.data_directory, filename
                      )
                  )
                  assert (
                      len(df) > 20
                  ), f"The input time series length ({len(df)}) is too small."
                  if file_mode == "single":
                      n = int(int(train_percentage) * len(df) / 100)
                      train_df, test_df = df.iloc[:n], df.iloc[n:]
                  else:
                      assert test_filename, "The test file is empty!"
                      test_df = ForecastModel().load_data(
                          os.path.join(
                              file_manager.data_directory, test_filename
                          )
                      )
                      train_df = df
  
                  params = ForecastModel.parse_parameters(
                      param_info=ForecastModel.get_parameter_info(
                          algorithm
                      ),
                      params={
                          p["Parameter"]: p["Value"]
                          for p in table["props"]["data"]
                          if p["Parameter"]
                      },
                  )
                  (
                      model,
                      train_metrics,
                      test_metrics,
                      figure,
                  ) = ForecastModel().train(
                      algorithm,
                      train_df,
                      test_df,
                      target_col,
                      feature_cols,
                      exog_cols,
                      params,
                      set_progress,
                  )
                  ForecastModel.save_model(
                      file_manager.model_directory, model, algorithm
                  )
                  train_metric_table = create_metric_table(
                      train_metrics
                  )
                  test_metric_table = create_metric_table(test_metrics)
                  figure = dcc.Graph(figure=figure)
  
      except Exception:
          error = traceback.format_exc()
          modal_is_open = True
          modal_content = error
          logger.error(error)
  
      return (
          train_metric_table,
          test_metric_table,
          figure,
          modal_is_open,
          modal_content,
      )
  
file_path: merlion/merlion/dashboard/callbacks/forecast.py
imports: import logging
  import os
  import traceback
  import dash
  from dash import Input, Output, State, dcc, callback
  from merlion.dashboard.utils.file_manager import FileManager
  from merlion.dashboard.models.forecast import ForecastModel
  from merlion.dashboard.pages.utils import create_param_table, create_metric_table, create_empty_figure
label_desc: Use image node_id 8 for calling a global function with example usage: click_train_test(set_progress, n_clicks, modal_close, filename, target_col, feature_cols, exog_cols, algorithm, table, train_percentage, test_filename, file_mode) and returns: train_metric_table,  test_metric_table,  figure,  modal_is_open,  modal_content