code: def choose_model(model_args, results_df):
      """Chooses which model to use in StatsForecast.
  
      If the user passes 'auto' for their model_name, this will choose the best
      model based on in-sample cross validation performance. This will then modify
      the model_args dictionnary, replacing 'auto' with the best-performing model.
      """
      if model_args["model_name"] == "auto":
          model_args["model_name"] = get_best_model_from_results_df(
              results_df
          )
      model_args["season_length"] = get_season_length(
          model_args["frequency"]
      )
      model = model_dict[model_args["model_name"]]
      return model(season_length=model_args["season_length"])
  
file_path: mindsdb/mindsdb/integrations/handlers/statsforecast_handler/statsforecast_handler.py
imports: import pandas
  import dill
  from mindsdb.integrations.libs.base import BaseMLEngine
  from mindsdb.integrations.utilities.time_series_utils import transform_to_nixtla_df, get_results_from_nixtla_df, infer_frequency, get_best_model_from_results_df, get_model_accuracy_dict, reconcile_forecasts, get_hierarchy_from_df
  from sklearn.metrics import r2_score
  from statsforecast import StatsForecast
  from statsforecast.models import AutoARIMA, AutoCES, AutoETS, AutoTheta
label_desc: Use image node_id 3 for calling a global function with example usage: choose_model(model_args, results_df) and returns: model