Prevent failing when there is no valid set (#1328)
Prevent failing when there is no valid set (#1328)

Summary:
# Before submitting

- [ ] Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
- [x] Did you read the [contributor guideline](https://github.com/pytorch/fairseq/blob/master/CONTRIBUTING.md)?
- [x] Did you make sure to update the docs?
- [x] Did you write any new necessary tests?

## What does this PR do?
If the valid set is small or non-existent, Fairseq will fail because `valid_losses` will not have been defined anywhere. This fixes the issue.

## PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

## Did you have fun?
Make sure you had fun coding �

Pull Request resolved: https://github.com/fairinternal/fairseq-py/pull/1328

Reviewed By: myleott

Differential Revision: D24042313

Pulled By: joshim5

fbshipit-source-id: ef45ade8e2d5f853364a05e03f566968e9aaa089

pytorch/fairseq,pytorch/fairseq,pytorch/fairseq