Fix unflatten when dim is a negative integer (#31208)
Summary:
Changelog:
- Wrap dim to be a positive integer when dim is negative
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31208
Test Plan:
- Updated tests in test_namedtensor.py
Fixes https://github.com/pytorch/pytorch/issues/31184
Differential Revision: D19036569
Pulled By: zou3519
fbshipit-source-id: 86e01e20988dee7c4b6c73232f66282d687f9a2c