code: def _test_functionality(mock_system_resources_ctx_mgr, test_args):
      system_resources = test_args.get(
          "system_resources", {"num_cpus": 16, "num_gpus": 4}
      )
      total_resources = test_args.get(
          "total_resources", {"num_cpus": "auto", "num_gpus": "auto"}
      )
      model_default_resources = test_args.get(
          "model_default_resources", {"num_cpus": 1, "num_gpus": 0}
      )
      model_minimum_resources = test_args.get(
          "model_minimum_resources", {"num_cpus": 1, "num_gpus": 0}
      )
      ag_args_ensemble = test_args.get("ag_args_ensemble", {})
      ag_args_fit = test_args.get("ag_args_fit", {})
      num_bag_folds = test_args.get("num_bag_folds", 0)
      fold_strategy_cls = test_args.get(
          "fold_strategy_cls", ParallelLocalFoldFittingStrategy
      )
      num_trials = test_args.get("num_trials", 0)
      executor_cls = test_args.get("executor_cls", RayHpoExecutor)
      expected_answer = test_args.get("expected_answer")
      hpo = num_trials > 0
      parallel_hpo = hpo and executor_cls == RayHpoExecutor
      with mock_system_resources_ctx_mgr(
          num_cpus=system_resources.get("num_cpus"),
          num_gpus=system_resources.get("num_gpus"),
      ):
          model = DummyModel(
              minimum_resources=model_minimum_resources,
              default_resources=model_default_resources,
              hyperparameters={"ag_args_fit": ag_args_fit},
          )
          model.initialize()
          if num_bag_folds > 0:
              model = DummyBaggedModel(
                  model,
                  hyperparameters={"ag_args_fit": ag_args_ensemble},
              )
              model.initialize()
          resources = model._preprocess_fit_resources(
              total_resources=total_resources,
              k_fold=num_bag_folds,
              parallel_hpo=parallel_hpo,
          )
          resources.pop("k_fold")
          if hpo:
              hyperparameter_tune_kwargs = {
                  "scheduler": "local",
                  "searcher": "random",
                  "num_trials": num_trials,
              }
              executor = _initialize_executor(
                  executor_cls, hyperparameter_tune_kwargs
              )
              executor.register_resources(
                  model, k_fold=num_bag_folds, X=dummy_x, **resources
              )
              resources_per_trial = executor.hyperparameter_tune_kwargs[
                  "resources_per_trial"
              ]
              assert (
                  resources_per_trial
                  == expected_answer["resources_per_trial"]
              )
              if num_bag_folds > 0:
                  _test_bagging(
                      fold_strategy_cls=fold_strategy_cls,
                      num_jobs=num_bag_folds,
                      num_folds_parallel=num_bag_folds,
                      model_base=model.model_base,
                      bagged_model=model,
                      resources=resources_per_trial,
                      expected_answer=expected_answer,
                  )
          else:
              if num_bag_folds > 0:
                  _test_bagging(
                      fold_strategy_cls=fold_strategy_cls,
                      num_jobs=num_bag_folds,
                      num_folds_parallel=num_bag_folds,
                      model_base=model.model_base,
                      bagged_model=model,
                      resources=resources,
                      expected_answer=expected_answer,
                  )
              else:
                  assert (
                      resources
                      == expected_answer["resources_per_model"]
                  )
  
imports: import time
  import numpy
  import pandas
  import pytest
  from autogluon.core.hpo.executors import CustomHpoExecutor, RayHpoExecutor
  from autogluon.core.models.ensemble.bagged_ensemble_model import BaggedEnsembleModel
  from autogluon.core.models.ensemble.fold_fitting_strategy import ParallelLocalFoldFittingStrategy, SequentialLocalFoldFittingStrategy
  from autogluon.tabular.models import AbstractModel
label_desc: Use image node_id 5 for calling a global function with example usage: _test_functionality(mock_system_resources_ctx_mgr, test_args) without return types