code: def test_callbacks_restore_backbone(tmpdir):
      """Test callbacks restore is called after optimizers have been re-created but before optimizer states reload."""
  
      ckpt = ModelCheckpoint(dirpath=tmpdir, save_last=True)
      trainer = Trainer(
          default_root_dir=tmpdir,
          limit_train_batches=1,
          limit_val_batches=1,
          max_epochs=2,
          enable_progress_bar=False,
          callbacks=[
              ckpt,
              BackboneFinetuning(unfreeze_backbone_at_epoch=1),
          ],
      )
      trainer.fit(BackboneBoringModel())
  
      # initialize a trainer that continues the previous training
      trainer = Trainer(
          default_root_dir=tmpdir,
          limit_train_batches=1,
          limit_val_batches=1,
          max_epochs=3,
          enable_progress_bar=False,
          callbacks=BackboneFinetuning(unfreeze_backbone_at_epoch=1),
      )
      trainer.fit(BackboneBoringModel(), ckpt_path=ckpt.last_model_path)
  
imports: from collections import OrderedDict
  import pytest
  import torch
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_1_13
  from lightning.pytorch import LightningModule, Trainer, seed_everything
  from lightning.pytorch.callbacks import BackboneFinetuning, BaseFinetuning, ModelCheckpoint
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from torch import nn
  from torch.optim import SGD, Optimizer
  from torch.utils.data import DataLoader
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 8 for calling a global function with example usage: test_callbacks_restore_backbone(tmpdir) without return types