code: def test_timer_resume_training(tmpdir):
      """Test that the timer can resume together with the Trainer."""
      model = BoringModel()
      timer = Timer(duration=timedelta(milliseconds=200))
      checkpoint_callback = ModelCheckpoint(
          dirpath=tmpdir, save_top_k=-1
      )
  
      # initial training
      trainer = Trainer(
          default_root_dir=tmpdir,
          max_epochs=100,
          callbacks=[timer, checkpoint_callback],
      )
      trainer.fit(model)
      assert not timer._offset
      assert timer.time_remaining() <= 0
      assert trainer.current_epoch < 99
      saved_global_step = trainer.global_step
  
      # resume training (with depleted timer)
      timer = Timer(duration=timedelta(milliseconds=200))
      trainer = Trainer(default_root_dir=tmpdir, callbacks=timer)
      trainer.fit(model, ckpt_path=checkpoint_callback.best_model_path)
      assert timer._offset > 0
      assert trainer.global_step == saved_global_step
  
imports: import logging
  import time
  from datetime import timedelta
  from unittest.mock import Mock, patch
  import pytest
  from lightning.pytorch import Trainer
  from lightning.pytorch.callbacks import ModelCheckpoint
  from lightning.pytorch.callbacks.timer import Timer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 8 for calling a global function with example usage: test_timer_resume_training(tmpdir) without return types