Add invariants check to BatchedTensorImpl (#40171)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/40171
It checks that all of the bdims in BatchedTensorImpl are sorted in
order of ascending `level`.
Test Plan: - Check that nothing breaks in `./build/bin/vmap_test`
Differential Revision: D22102077
Pulled By: zou3519
fbshipit-source-id: 094b7abc6c65208437f0f51a0d0083091912decc