code: def test_init_optimizers_resets_lightning_optimizers(tmpdir):
      """Test that the Trainer resets the `lightning_optimizers` list everytime new optimizers get initialized."""
  
      def compare_optimizers():
          assert (
              trainer.strategy._lightning_optimizers[0].optimizer
              is trainer.optimizers[0]
          )
  
      model = BoringModel()
      model.lr = 0.2
      trainer = Trainer(default_root_dir=tmpdir, max_epochs=1)
      tuner = Tuner(trainer)
  
      tuner.lr_find(model)
      compare_optimizers()
  
      trainer.fit(model)
      compare_optimizers()
  
      trainer.fit_loop.max_epochs = 2  # simulate multiple fit calls
      trainer.fit(model)
      compare_optimizers()
  
imports: from copy import deepcopy
  from unittest.mock import DEFAULT, Mock, patch
  import pytest
  import torch
  from lightning.pytorch import Trainer
  from lightning.pytorch.core.optimizer import LightningOptimizer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.loops.optimization.automatic import Closure
  from lightning.pytorch.tuner.tuning import Tuner
  from torch.optim import SGD, Adam, Optimizer
label_desc: Use image node_id 2 for calling a global function with example usage: test_init_optimizers_resets_lightning_optimizers(tmpdir) without return types