code: def test_correct_step_and_epoch(tmpdir):
      model = BoringModel()
      first_max_epochs = 2
      train_batches = 2
      trainer = Trainer(
          default_root_dir=tmpdir,
          max_epochs=first_max_epochs,
          limit_train_batches=train_batches,
          limit_val_batches=0,
      )
      assert trainer.current_epoch == 0
      assert trainer.global_step == 0
  
      trainer.fit(model)
      assert trainer.current_epoch == first_max_epochs
      assert trainer.global_step == first_max_epochs * train_batches
  
      # save checkpoint after loop ends, training end called, epoch count increased
      ckpt_path = str(tmpdir / "model.ckpt")
      trainer.save_checkpoint(ckpt_path)
  
      ckpt = torch.load(ckpt_path)
      assert ckpt["epoch"] == first_max_epochs
      assert ckpt["global_step"] == first_max_epochs * train_batches
  
      max_epochs = first_max_epochs + 2
      trainer = Trainer(
          default_root_dir=tmpdir,
          max_epochs=max_epochs,
          limit_train_batches=train_batches,
          limit_val_batches=0,
      )
      # the ckpt state is not loaded at this point
      assert trainer.current_epoch == 0
      assert trainer.global_step == 0
  
      class TestModel(BoringModel):
          def on_train_start(self) -> None:
              assert self.trainer.current_epoch == first_max_epochs
              assert (
                  self.trainer.global_step
                  == first_max_epochs * train_batches
              )
              assert (
                  self.trainer.fit_loop.epoch_loop._batches_that_stepped
                  == first_max_epochs * train_batches
              )
  
      trainer.fit(TestModel(), ckpt_path=ckpt_path)
      assert trainer.current_epoch == max_epochs
      assert trainer.global_step == max_epochs * train_batches
      assert (
          trainer.fit_loop.epoch_loop._batches_that_stepped
          == max_epochs * train_batches
      )
  
imports: import glob
  import logging
  import os
  import pickle
  from copy import deepcopy
  from typing import Generic, Mapping, TypeVar
  import cloudpickle
  import pytest
  import torch
  from lightning.fabric import seed_everything
  from lightning.pytorch import Callback, Trainer
  from lightning.pytorch.callbacks import ModelCheckpoint
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.trainer.states import TrainerFn
  from lightning_utilities.test.warning import no_warning_call
  from torch import Tensor
  import tests_pytorch.helpers.pipelines
  import tests_pytorch.helpers.utils
  from tests_pytorch.helpers.datamodules import ClassifDataModule
  from tests_pytorch.helpers.runif import RunIf
  from tests_pytorch.helpers.simple_models import ClassificationModel
  from tests_pytorch.loops.test_loops import CustomException
label_desc: Use image node_id 3 for calling a global function with example usage: test_correct_step_and_epoch(tmpdir) without return types