code: def test_toggle_untoggle_2_optimizers_no_shared_parameters(tmpdir):
      class TestModel(BoringModel):
          def __init__(self):
              super().__init__()
              self.automatic_optimization = False
              self.layer_1 = nn.Sequential(
                  nn.Linear(32, 32),
                  nn.ReLU(),
                  nn.Linear(32, 32),
                  nn.ReLU(),
                  nn.Linear(32, 32),
              )
  
              self.layer_2 = nn.Sequential(
                  nn.ReLU(),
                  nn.Linear(32, 32),
                  nn.ReLU(),
                  nn.Linear(32, 32),
                  nn.ReLU(),
                  nn.Linear(32, 2),
              )
  
              # set some weights to require no gradient to check that toggle/untoggle works as expected.
              self.layer_1[2].weight.requires_grad = False
              self.layer_1[4].weight.requires_grad = False
  
              self.layer_2[1].weight.requires_grad = False
              self.layer_2[3].weight.requires_grad = False
  
          def training_step(self, batch, batch_idx):
              opt1, opt2 = self.optimizers()
  
              # Use the first optimizer, toggle it
              self.toggle_optimizer(opt1)
              loss = self.step(batch)
              opt1.zero_grad()
              self.manual_backward(loss)
              assert self.layer_1[0].weight.requires_grad is True
              assert self.layer_1[2].weight.requires_grad is False
              assert self.layer_1[4].weight.requires_grad is False
  
              assert self.layer_2[1].weight.requires_grad is False
              assert self.layer_2[3].weight.requires_grad is False
              assert self.layer_2[5].weight.requires_grad is False
              opt1.step()
              self.untoggle_optimizer(opt1)
  
              # Use the second optimizer, toggle it
              self.toggle_optimizer(opt2)
              loss = self.step(batch)
              opt2.zero_grad()
              self.manual_backward(loss)
              assert self.layer_1[0].weight.requires_grad is False
              assert self.layer_1[2].weight.requires_grad is False
              assert self.layer_1[4].weight.requires_grad is False
  
              assert self.layer_2[1].weight.requires_grad is False
              assert self.layer_2[3].weight.requires_grad is False
              assert self.layer_2[5].weight.requires_grad is True
              opt2.step()
              self.untoggle_optimizer(opt2)
  
          def configure_optimizers(self):
              optimizer_1 = SGD(self.layer_1.parameters(), lr=0.1)
              optimizer_2 = Adam(self.layer_2.parameters(), lr=0.1)
              return [optimizer_1, optimizer_2]
  
      model = TestModel()
  
      trainer = Trainer(
          max_epochs=1,
          default_root_dir=tmpdir,
          limit_train_batches=8,
          limit_val_batches=0,
      )
      trainer.fit(model)
  
imports: import sys
  import weakref
  from unittest.mock import Mock
  import pytest
  import torch
  from lightning.fabric import Fabric
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_1_13, _TORCH_GREATER_EQUAL_2_0
  from lightning.pytorch import LightningModule, Trainer
  from lightning.pytorch.core.module import _TrainerFabricShim
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.loggers import TensorBoardLogger
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from torch import nn
  from torch.optim import SGD, Adam
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 9 for calling a global function with example usage: test_toggle_untoggle_2_optimizers_no_shared_parameters(tmpdir) and returns: list