Failed to configure_optimizers from dictionary without lr_scheduler field presented
🐛 Bug
Optimizer is failed to be configured from the dictionary without lr_sheduler field.
Consider an example of the Module configure_optimizers method:
        def configure_optimizers(self):
            config = {
                'optimizer': torch.optim.SGD(params=self.parameters(), lr=1e-03)
            }
            return config
Then, we run a simple trainer:
    trainer_options = dict(default_save_path=tmpdir, max_epochs=1)
    trainer = Trainer(**trainer_options)
    _ = trainer.fit(model)
And we fail with an error:
UnboundLocalError: local variable 'lr_schedulers' referenced before assignment

I believe, that the reason is that lr_schedulers local variable is not determined here:

  
    
      pytorch-lightning/pytorch_lightning/trainer/optimizers.py
    
    
        Lines 36 to 42
      in
      8dd9b80
    
  
  
    

        
          
           # single dictionary 
        

        
          
           elif isinstance(optim_conf, dict): 
        

        
          
               optimizer = optim_conf["optimizer"] 
        

        
          
               lr_scheduler = optim_conf.get("lr_scheduler", []) 
        

        
          
               if lr_scheduler: 
        

        
          
                   lr_schedulers = self.configure_schedulers([lr_scheduler]) 
        

        
          
               return [optimizer], lr_schedulers, [] 
        
    
  


I think, it could be fixed like this:
        # single dictionary
        elif isinstance(optim_conf, dict):
            optimizer = optim_conf["optimizer"]
            lr_scheduler = optim_conf.get("lr_scheduler", [])
            if lr_scheduler:
                lr_schedulers = self.configure_schedulers([lr_scheduler])
            else:
                lr_schedulers = []
            return [optimizer], lr_schedulers, []
To Reproduce
Steps to reproduce the behavior:

Create a simple Module with configure_optimizers which looks like above.
Run the fit Trainer method with the model.
See error

Code sample
https://gist.github.com/alexeykarnachev/c61a5b1ca3bf876e19b4547eeb9f42dc
Expected behavior
I suppose, that such the configuration: {"optimizer": ...}, without "lr_scheduler" must be a valid one, and this error must not be occurred.
Environment
OS: Linux
architecture: 64bit
processor: x86_64
python: 3.7.6
version: #97~16.04.1-Ubuntu SMP Wed Apr 1 03:03:31 UTC 2020
pytorch-lightning: 0.7.3rc1