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,
  ):
      """Training script for hyperparameter evaluation of an arbitrary model that subclasses AbstractModel."""
      try:
          if fit_kwargs is None:
              fit_kwargs = dict()
  
          model = init_model(
              args=args,
              model_cls=model_cls,
              init_params=init_params,
              backend=hpo_executor.executor_type,
              is_bagged_model=is_bagged_model,
          )
  
          X, y = load_pkl.load(train_path)
          X_val, y_val = load_pkl.load(val_path)
  
          fit_model_args = dict(
              X=X, y=y, X_val=X_val, y_val=y_val, **fit_kwargs
          )
          predict_proba_args = dict(X=X_val)
          model = fit_and_save_model(
              model=model,
              fit_args=fit_model_args,
              predict_proba_args=predict_proba_args,
              y_val=y_val,
              time_start=time_start,
              time_limit=time_limit,
          )
      except Exception as e:
          if not isinstance(e, TimeLimitExceeded):
              logger.exception(e, exc_info=True)
          # 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/core/src/autogluon/core/models/abstract/model_trial.py
imports: import logging
  import os
  import time
  from ...hpo.constants import CUSTOM_BACKEND, RAY_BACKEND, VALID_BACKEND
  from ...utils.exceptions import TimeLimitExceeded
  from ...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