def optimizer_step(self, optimizer, opt_idx, batch_idx, train_step_and_backward_closure):
    model_ref = self.trainer.lightning_module
    is_lbfgs = isinstance(optimizer, torch.optim.LBFGS)
    using_native_amp = (self.trainer.amp_backend == AMPType.NATIVE)
    if (using_native_amp and is_lbfgs):
        raise MisconfigurationException('native PyTorch amp and lbfgs are not compatible. To request, please file a Github issue in PyTorch and tag @mcarilli')
    optimizer = LightningOptimizer._to_lightning_optimizer(optimizer, self.trainer, opt_idx)
    model_ref.optimizer_step(self.trainer.current_epoch, batch_idx, optimizer, opt_idx, train_step_and_backward_closure, on_tpu=((self.trainer._device_type == DeviceType.TPU) and _TPU_AVAILABLE), using_native_amp=using_native_amp, using_lbfgs=is_lbfgs)
def optimizer_step(self, optimizer, opt_idx, batch_idx, train_step_and_backward_closure):
    model_ref = self.trainer.lightning_module
    is_lbfgs = isinstance(optimizer, torch.optim.LBFGS)
    using_native_amp = (self.trainer.amp_backend == AMPType.NATIVE)
    if (using_native_amp and is_lbfgs):
        raise MisconfigurationException('native PyTorch amp and lbfgs are not compatible. To request, please file a Github issue in PyTorch and tag @mcarilli')
    optimizer = LightningOptimizer._to_lightning_optimizer(optimizer, self.trainer, opt_idx)
    model_ref.optimizer_step(self.trainer.current_epoch, batch_idx, optimizer, opt_idx, train_step_and_backward_closure, on_tpu=((self.trainer._device_type == DeviceType.TPU) and _TPU_AVAILABLE), using_native_amp=using_native_amp, using_lbfgs=is_lbfgs)