code: def _test_resource_allocation_and_time_limit(
      num_jobs, num_folds_parallel, time_limit
  ):
      num_cpus = ResourceManager.get_cpu_count()
      num_gpus = ResourceManager.get_gpu_count()
      time_start = time.time()
      fold_fitting_strategy = _construct_dummy_fold_strategy(
          num_jobs=num_jobs,
          time_limit=time_limit,
          num_folds_parallel=num_folds_parallel,
      )
      for i in range(num_jobs):
          fold_fitting_strategy.schedule_fold_model_fit(dict())
      resources, batches, num_parallel_jobs = (
          fold_fitting_strategy.resources,
          fold_fitting_strategy.batches,
          fold_fitting_strategy.num_parallel_jobs,
      )
      time_elapsed = time.time() - time_start
      time_remaining = time_limit - time_elapsed
      time_limit_fold = fold_fitting_strategy._get_fold_time_limit()
      num_cpus_per_job = resources.get("num_cpus", 0)
      num_gpus_per_job = resources.get("num_gpus", 0)
      assert batches >= 1
      if batches > 1:
          assert (
              num_jobs
              <= num_parallel_jobs * batches
              <= (num_jobs + num_parallel_jobs)
          )
      assert num_cpus_per_job * num_parallel_jobs <= num_cpus
      if num_gpus != 0:
          assert num_gpus_per_job * num_parallel_jobs <= num_gpus
      else:
          assert num_gpus_per_job == 0
      assert math.isclose(
          time_limit_fold, (time_remaining / batches), abs_tol=0.5
      )
  
file_path: autogluon/core/tests/unittests/test_parallel_local_folding.py
imports: import math
  import time
  from unittest.mock import patch
  import numpy
  import pandas
  from autogluon.common import space
  from autogluon.common.utils.resource_utils import ResourceManager
  from autogluon.core.models import AbstractModel
  from autogluon.core.models.ensemble.bagged_ensemble_model import BaggedEnsembleModel
  from autogluon.core.models.ensemble.fold_fitting_strategy import ParallelLocalFoldFittingStrategy
  from autogluon.core.searcher import LocalRandomSearcher
label_desc: Use image node_id 3 for calling a global function with example usage: _test_resource_allocation_and_time_limit(num_jobs, num_folds_parallel, time_limit) without return types