code: def test_dynamic_resource_allocation(mock_get_mem):
      mock_get_mem.return_value = 2.5 * 1e9
      fold_fitting_strategy = _construct_dummy_fold_strategy(
          model_base_cls=DummyBigModel, num_jobs=8, num_folds_parallel=8
      )
      assert (
          fold_fitting_strategy.num_parallel_jobs == 2
          and fold_fitting_strategy.batches == 4
      )
      mock_get_mem.return_value = 7.5 * 1e9
      fold_fitting_strategy = _construct_dummy_fold_strategy(
          model_base_cls=DummyBigModel, num_jobs=8, num_folds_parallel=8
      )
      # If memory is not sufficient to train num_folds_parallel, reduce to max power of 2 folds that's smaller than folds_can_be_fit_in_parallel.
      # Here memory can only train 7 folds, therefore we train 4 folds instead in two batches
      assert (
          fold_fitting_strategy.num_parallel_jobs == 4
          and fold_fitting_strategy.batches == 2
      )
      mock_get_mem.return_value = 6 * 1e9
      fold_fitting_strategy = _construct_dummy_fold_strategy(
          model_base_cls=DummyBigModel,
          num_jobs=10,
          num_folds_parallel=10,
      )
      # Here memory can only train 10 folds, therefore we train 4 folds instead in three batches, the last batch would train 2 folds in parallel
      assert (
          fold_fitting_strategy.num_parallel_jobs == 4
          and fold_fitting_strategy.batches == 3
      )
  
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 5 for calling a global function with example usage: test_dynamic_resource_allocation(mock_get_mem) without return types