def _after_closure(self, model: "pl.LightningModule", optimizer: Steppable) -> None:
        """Utility to share some code after the closure has been run."""
        trainer = model.trainer
        call._call_callback_hooks(trainer, "on_before_optimizer_step", optimizer)
        call._call_lightning_module_hook(trainer, "on_before_optimizer_step", optimizer)
        self._clip_gradients(
            model,
            optimizer,
            trainer.gradient_clip_val,
            gradient_clip_algorithm=trainer.gradient_clip_algorithm,
        )
Utility to share some code after the closure has been run.
src/lightning/pytorch/plugins/precision/precision.py