[fix] repr(torch.device) (#48655)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/48585
In the following commit https://github.com/pytorch/pytorch/commit/4c9eb57914fb538e21c46b63cfb5c2e9d5bc2f20, type of `DeviceIndex` was changed from `uint16_t` to `uint8_t`.
`uint8_t` is treated as ascii chars by std::cout and other stream operators. Hence the broken `repr`
Stackoverflow Reference: https://stackoverflow.com/questions/19562103/uint8-t-cant-be-printed-with-cout
Pull Request resolved: https://github.com/pytorch/pytorch/pull/48655
Reviewed By: bdhirsh
Differential Revision: D25272289
Pulled By: ezyang
fbshipit-source-id: a1549f5f8d417138cf38795e4c373e3a487d3691