code: def test_amp_fused_optimizer_parity(tmpdir):
      def run(fused=False):
          seed_everything(1234)
          model = FusedOptimizerParityModel(fused)
          trainer = Trainer(
              default_root_dir=tmpdir,
              accelerator="cuda",
              devices=1,
              precision="16-mixed",
              max_steps=5,
              logger=False,
              enable_checkpointing=False,
              enable_progress_bar=False,
              enable_model_summary=False,
          )
          trainer.fit(model)
          return model.parameters()
  
      params = run(fused=False)
      params_fused = run(fused=True)
  
      # Both the regular and the fused version of Adam produce the same losses and model weights
      for p, q in zip(params, params_fused):
          torch.testing.assert_close(p, q)
  
file_path: pytorch-lightning/tests/tests_pytorch/plugins/precision/test_amp_integration.py
imports: from unittest.mock import Mock
  import torch
  from lightning.fabric import seed_everything
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.plugins.precision import MixedPrecision
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 1 for calling a global function with example usage: test_amp_fused_optimizer_parity(tmpdir) and returns: model