code: def test_callback_save_restore(
      ray_start_4_cpus_2_gpus_extra, resource_manager_cls, tmpdir
  ):
      """Check that callback state is restored correctly.
  
      Legacy test: test_trial_runner_3.py::TrialRunnerTest::testCallbackSaveRestore
      """
      storage = mock_storage_context()
      runner = TuneController(
          callbacks=[StatefulCallback()], storage=storage
      )
      runner.add_trial(Trial("__fake", stub=True, storage=storage))
      for i in range(3):
          runner._callbacks.on_trial_result(
              iteration=i, trials=None, trial=None, result=None
          )
      runner.checkpoint(force=True)
      callback = StatefulCallback()
      runner2 = TuneController(callbacks=[callback], storage=storage)
      assert callback.counter == 0
      runner2.resume()
      assert callback.counter == 3
  
file_path: ray/python/ray/tune/tests/execution/test_controller_callback_integration.py
imports: from typing import Dict, Optional
  import pytest
  import sys
  import ray
  from ray.air.execution import FixedResourceManager, PlacementGroupResourceManager
  from ray.tune import Callback
  from ray.tune.execution.tune_controller import TuneController
  from ray.tune.experiment import Trial
  from ray.train.tests.util import mock_storage_context
label_desc: Use image node_id 2 for calling a global function with example usage: test_callback_save_restore(ray_start_4_cpus_2_gpus_extra, resource_manager_cls, tmpdir) without return types