Training of machine translation model fails if config parameter `trainer.max_epochs` is used instead of `trainer.max_steps`.
State: closed | Pull request: no
Labels: name: bug

**Describe the bug**

Training of machine translation model fails if config parameter `trainer.max_epochs` is used. Method `ModelPT.setup_optimization` tries to get deprecated `pytorch_lightning.Trainer` parameter `distributed_backend`.

```
Traceback (most recent call last):                                                                                                                                                                       
  File "enc_dec_nmt.py", line 133, in main                                                                                                                                                                 
    trainer.fit(mt_model)                                                                                                                                                                                
  File "/home/apeganov/anaconda3/envs/megatron/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 640, in fit
    self._call_and_handle_interrupt(self._fit_impl, model, train_dataloaders, val_dataloaders, datamodule)
  File "/home/apeganov/anaconda3/envs/megatron/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 592, in _call_and_handle_interrupt
    return trainer_fn(*args, **kwargs)
  File "/home/apeganov/anaconda3/envs/megatron/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 670, in _fit_impl
    self._run(model)
  File "/home/apeganov/anaconda3/envs/megatron/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1049, in _run
    self.accelerator.setup(self)
  File "/home/apeganov/anaconda3/envs/megatron/lib/python3.8/site-packages/pytorch_lightning/accelerators/gpu.py", line 46, in setup
    return super().setup(trainer)
  File "/home/apeganov/anaconda3/envs/megatron/lib/python3.8/site-packages/pytorch_lightning/accelerators/accelerator.py", line 92, in setup
    self.setup_optimizers(trainer)                                                                                                                                                                       
  File "/home/apeganov/anaconda3/envs/megatron/lib/python3.8/site-packages/pytorch_lightning/accelerators/accelerator.py", line 364, in setup_optimizers
    optimizers, lr_schedulers, optimizer_frequencies = self.training_type_plugin.init_optimizers(
  File "/home/apeganov/anaconda3/envs/megatron/lib/python3.8/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 250, in init_optimizers
    return trainer.init_optimizers(model)
  File "/home/apeganov/anaconda3/envs/megatron/lib/python3.8/site-packages/pytorch_lightning/trainer/optimizers.py", line 35, in init_optimizers
    optim_conf = self.call_hook("configure_optimizers", pl_module=pl_module)
  File "/home/apeganov/anaconda3/envs/megatron/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1398, in call_hook
    output = model_fx(*args, **kwargs)
  File "/home/apeganov/NeMo/nemo/core/classes/modelPT.py", line 575, in configure_optimizers
    self.setup_optimization()
  File "/home/apeganov/NeMo/nemo/core/classes/modelPT.py", line 463, in setup_optimization
    if self._trainer.distributed_backend is None:
AttributeError: 'Trainer' object has no attribute 'distributed_backend'
```

**Steps/Code to reproduce bug**

Replace `trainer.max_steps` with `trainer.max_epochs` in any machine translation config and launch training
```
python enc_dec_nmt.py --config-name <your_config>
```


**Expected behavior**

Normal training without errors.

**Environment overview (please complete the following information)**

 - Environment location: Bare-metal
 - Method of NeMo install: pip

**Environment details**

If NVIDIA docker image is used you don't need to specify these.
Otherwise, please provide:
- OS version: Ubuntu 20.04.2 LTS
- PyTorch version: 1.10.0
- Python version: 3.8