[lint] upgrade mypy to latest version
Fixes https://github.com/pytorch/pytorch/issues/75927.
Had to fix some bugs and add some ignores.
To check if clean:
```
lintrunner --paths-cmd='git grep -Il .' --take MYPY,MYPYSTRICT
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/76753
Approved by: https://github.com/malfet