code: def model_trial(
      args,
      model_cls,
      init_params,
      train_path,
      val_path,
      time_start,
      hpo_executor,
      is_bagged_model=False,
      reporter=None,  # reporter only used by custom strategy, hence optional
      time_limit=None,
      fit_kwargs=None,
  ):
      """Runs a single trial of a hyperparameter tuning. Replaces
      `core.models.abstract.model_trial.model_trial` for timeseries models.
      """
      try:
          model = init_model(
              args,
              model_cls,
              init_params,
              backend=hpo_executor.executor_type,
              is_bagged_model=is_bagged_model,
          )
          model.set_contexts(
              path_context=os.path.join(model.path_root, model.name)
          )
  
          train_data = load_pkl.load(train_path)
          val_data = load_pkl.load(val_path)
  
          eval_metric = model.eval_metric
  
          model = fit_and_save_model(
              model,
              fit_kwargs,
              train_data,
              val_data,
              eval_metric,
              time_start=time_start,
              time_limit=time_limit,
          )
  
      except Exception as err:
          if not isinstance(err, TimeLimitExceeded):
              logger.error(
                  f"\tWarning: Exception caused {model.name} to fail during training... Skipping this model."
              )
              logger.error(f"\t{err}")
              logger.debug(traceback.format_exc())
          # In case of TimeLimitExceed, val_score could be None
          hpo_executor.report(
              reporter=reporter,
              epoch=1,
              validation_performance=model.val_score
              if model.val_score is not None
              else float("-inf"),
          )
          if reporter is not None:
              reporter.terminate()
      else:
          hpo_executor.report(
              reporter=reporter,
              epoch=1,
              validation_performance=model.val_score,
          )
  
file_path: autogluon/timeseries/src/autogluon/timeseries/models/abstract/model_trial.py
imports: import logging
  import os
  import time
  import traceback
  from autogluon.core.models.abstract.model_trial import init_model
  from autogluon.core.utils.exceptions import TimeLimitExceeded
  from autogluon.core.utils.loaders import load_pkl
label_desc: Use image node_id 1 for calling a global function with example usage: model_trial(args, model_cls, init_params, train_path, val_path, time_start, hpo_executor, is_bagged_model, reporter, time_limit, fit_kwargs) without return types