Make type of `Tensor.type()` more specific (#32353)
Summary:
Fixes the following issue:
```
$ cat test.py
import torch
t = torch.tensor(1.5)
t.type(torch.float32)[None]
$ mypy test.py
test.py:4: error: Invalid index type "None" for "Union[str, Tensor]"; expected type "Union[int, slice]"
Found 1 error in 1 file (checked 1 source file)
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32353
Differential Revision: D19499388
Pulled By: ezyang
fbshipit-source-id: 715111e934aea020b20f850d27e32c4f70b82572
Author
Bartosz Gasiorzewski