Stricter boundary checks on CountingIterator (#2491)
Stricter boundary checks on CountingIterator (#2491)

Summary:
We were previously a bit too lenient with boundary conditions to support `CountingIterator.take`. Let's instead handle this more explicitly.

Pull Request resolved: https://github.com/pytorch/fairseq/pull/2491

Reviewed By: ngoyal2707

Differential Revision: D23172408

Pulled By: myleott

fbshipit-source-id: 90d24b044812982f7d3eb4cdb39f3db3016a884d

pytorch/fairseq,pytorch/fairseq,pytorch/fairseq