code: def init_model(
      args, model_cls, init_params, backend, is_bagged_model=False
  ):
      args = args.copy()
  
      if backend == CUSTOM_BACKEND:
          task_id = args.pop("task_id")
          file_prefix = f"T{task_id+1}"  # append to all file names created during this trial. Do NOT change!
      elif backend == RAY_BACKEND:
          from ray import tune
  
          task_id = tune.get_trial_id()
          file_prefix = task_id
      else:
          raise ValueError(
              f"Invalid backend: {backend}. Valid options are [{CUSTOM_BACKEND}, {RAY_BACKEND}]"
          )
  
      if is_bagged_model:
          if "model_base_kwargs" not in init_params:
              init_params["model_base_kwargs"] = {}
          if "hyperparameters" not in init_params["model_base_kwargs"]:
              init_params["model_base_kwargs"]["hyperparameters"] = {}
          init_params["model_base_kwargs"]["hyperparameters"].update(
              args
          )
      else:
          if "hyperparameters" not in init_params:
              init_params["hyperparameters"] = {}
          init_params["hyperparameters"].update(args)
      init_params["name"] = os.path.join(
          init_params["name"], file_prefix
      )
  
      return model_cls(**init_params)
  
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 2 for calling a global function with example usage: init_model(args, model_cls, init_params, backend, is_bagged_model) and returns: model_cls