def untoggle_optimizer(self, optimizer: Union[Optimizer, LightningOptimizer]) -> None:
        """Resets the state of required gradients that were toggled with :meth:`toggle_optimizer`.

        Args:
            optimizer: The optimizer to untoggle.

        """
        for opt in self.trainer.optimizers:
            if not (opt is optimizer or (isinstance(optimizer, LightningOptimizer) and opt is optimizer.optimizer)):
                for group in opt.param_groups:
                    for param in group["params"]:
                        if param in self._param_requires_grad_state:
                            param.requires_grad = self._param_requires_grad_state[param]
        # save memory
        self._param_requires_grad_state = {}
Resets the state of required gradients that were toggled with :meth:`toggle_optimizer`.

        Args:
            optimizer: The optimizer to untoggle.

        
src/lightning/pytorch/core/module.py