code: def test_amp_fused_optimizer_parity():
      def run(fused=False):
          seed_everything(1234)
          fabric = Fabric(accelerator="cuda", precision=16, devices=1)
  
          model = nn.Linear(10, 10).to(
              fabric.device
          )  # TODO: replace with individual setup_module call
          optimizer = torch.optim.Adam(
              model.parameters(), lr=1.0, fused=fused
          )
  
          model, optimizer = fabric.setup(model, optimizer)
          assert isinstance(
              fabric._precision.scaler, torch.cuda.amp.GradScaler
          )
  
          data = torch.randn(10, 10, device="cuda")
          target = torch.randn(10, 10, device="cuda")
  
          losses = []
          for _ in range(5):
              optimizer.zero_grad()
              output = model(data)
              loss = (output - target).abs().sum()
              fabric.backward(loss)
              optimizer.step()
              losses.append(loss.detach())
          return torch.stack(losses), model.parameters()
  
      losses, params = run(fused=False)
      losses_fused, params_fused = run(fused=True)
  
      # Both the regular and the fused version of Adam produce the same losses and model weights
      torch.testing.assert_close(losses, losses_fused)
      for p, q in zip(params, params_fused):
          torch.testing.assert_close(p, q)
  
file_path: pytorch-lightning/tests/tests_fabric/plugins/precision/test_amp_integration.py
imports: import pytest
  import torch
  import torch.nn
  from lightning.fabric import Fabric, seed_everything
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 3 for calling a global function with example usage: test_amp_fused_optimizer_parity() and returns: torch,  model