code: def testAllocateFreeResources(self):
      scheduler = ResourceChangingScheduler(
          resources_allocation_function=DistributeResourcesToTopJob(
              add_bundles=True, metric="metric", mode="max"
          )
      )
  
      base_pgf = PlacementGroupFactory([{"CPU": 1, "GPU": 0}])
      trial1, trial2, trial3, trial4 = self._prepareTrials(
          scheduler, base_pgf
      )
  
      decision = scheduler.on_trial_result(
          self.tune_controller,
          trial2,
          {"metric": 0.9, "training_iteration": 4},
      )
      assert decision == TrialScheduler.CONTINUE
  
      self._allocateAndAssertNewResources(
          trial1, scheduler, PlacementGroupFactory([{"CPU": 1}] * 5)
      )
      decision = scheduler.on_trial_result(
          self.tune_controller,
          trial2,
          {"metric": 1.1, "training_iteration": 4},
      )
      assert decision == TrialScheduler.CONTINUE
      trial4.status = Trial.TERMINATED
  
      self._allocateAndAssertNewResources(
          trial2,
          scheduler,
          PlacementGroupFactory([{"CPU": 1}] * 2),
          metric=1.1,
      )
      trial3.status = Trial.TERMINATED
  
      self._allocateAndAssertNewResources(
          trial1,
          scheduler,
          PlacementGroupFactory([{"CPU": 1}] * 6),
          metric=1.2,
      )
  
      trial2.status = Trial.TERMINATED
  
      self._allocateAndAssertNewResources(
          trial1, scheduler, PlacementGroupFactory([{"CPU": 1}] * 8)
      )
  
imports: import shutil
  import tempfile
  import unittest
  from ray.tune import PlacementGroupFactory
  from ray.tune.execution.tune_controller import TuneController
  from ray.tune.schedulers.trial_scheduler import TrialScheduler
  from ray.tune.experiment import Trial
  from ray.tune.schedulers.resource_changing_scheduler import ResourceChangingScheduler, DistributeResources, DistributeResourcesToTopJob
  from ray.tune.tests.execution.utils import create_execution_test_objects
  from ray.train.tests.util import mock_storage_context
label_desc: Use image node_id 1 for calling the TestTopJobResourceAllocationAddBundles obj's underlying member method code with example usage: obj.testAllocateFreeResources() without return types