code: def test_migrate_loop_batches_that_stepped(tmpdir, model_class):
      trainer = Trainer(
          max_steps=1, limit_val_batches=0, default_root_dir=tmpdir
      )
      model = model_class()
      trainer.fit(model)
      ckpt_path = trainer.checkpoint_callback.best_model_path
  
      # pretend we have a checkpoint produced in < v1.6.5; the key "_batches_that_stepped" didn't exist back then
      ckpt = torch.load(ckpt_path)
      del ckpt["loops"]["fit_loop"]["epoch_loop.state_dict"][
          "_batches_that_stepped"
      ]
      _set_version(ckpt, "1.6.4")
      torch.save(ckpt, ckpt_path)
  
      class TestModel(model_class):
          def on_train_start(self) -> None:
              assert self.trainer.global_step == 1
              assert (
                  self.trainer.fit_loop.epoch_loop._batches_that_stepped
                  == 1
              )
  
      trainer = Trainer(
          max_steps=2, limit_val_batches=0, default_root_dir=tmpdir
      )
      model = TestModel()
      trainer.fit(model, ckpt_path=ckpt_path)
      new_loop = trainer.fit_loop.epoch_loop
      assert new_loop.global_step == new_loop._batches_that_stepped == 2
  
imports: from unittest.mock import ANY, MagicMock
  import lightning.pytorch
  import pytest
  import torch
  from lightning.fabric.utilities.warnings import PossibleUserWarning
  from lightning.pytorch import Trainer
  from lightning.pytorch.callbacks import EarlyStopping, ModelCheckpoint
  from lightning.pytorch.demos.boring_classes import BoringModel, ManualOptimBoringModel
  from lightning.pytorch.utilities.migration import migrate_checkpoint
  from lightning.pytorch.utilities.migration.utils import _get_version, _set_legacy_version, _set_version
label_desc: Use image node_id 4 for calling a global function with example usage: test_migrate_loop_batches_that_stepped(tmpdir, model_class) without return types