the NMT infer OOM 
**Is your feature request related to a problem? Please describe.**

1. Inference does not support automatic batch processing according to length, which leads to the OOM of excessively long sentences and makes it difficult to enlarge the beam.
2. And I found that as the inference goes on, the occupation of CUDA memory is gradually increasing.


A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
1. support automatic batch processing according to length
2. I have try to solve it by `torch.cuda.empty_cache()`

