set_dir expanding "~"
Fixes #69761.
Small change to torch.hub.set_dir() (<10 LOC).
It seems that before the code was split into `set_dir()` and `_get_torch_home `, an [earlier version](https://github.com/pytorch/pytorch/blame/5164622ba462fe07fc9f2325fccf7f85aecb3ec8/torch/hub.py#L111) of hub.py had a os.path.expanduser check.
Currently, [_get_torch_home](https://github.com/pytorch/pytorch/blob/master/torch/hub.py#L104) retained the os.path.expanduser check, but `set_dir()` didn't have one. This PR fixes that (I hope).
(As I mentioned in the issue, I can't run the tests on my laptop yet because of storage space :/ But I did include a test.)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69763
Approved by: https://github.com/malfet, https://github.com/NicolasHug