fix bugs in gen_pyi.py (#33748)
Summary:
This loop should generate type hints for inplace binary operator methods (`binop` variable) but had been using `name` variable. That's why that wrong type hints had been generated.
Resolve https://github.com/pytorch/pytorch/issues/33698
---
Current `__init__.pyi` has these type hints.
```python
class Tensor:
# some codes here...
overload
def zeros_like_(self, other: Union[Tensor, Number]) -> Tensor: ...
overload
def zeros_like_(self, value: Number, other: Union[Tensor, Number]) -> Tensor: ...
overload
def zeros_like_(self, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def zeros_like_(self, value: Number, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def zeros_like__(self, other: Union[Tensor, Number]) -> Tensor: ...
overload
def zeros_like__(self, value: Number, other: Union[Tensor, Number]) -> Tensor: ...
overload
def zeros_like__(self, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def zeros_like__(self, value: Number, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def zeros_like___(self, other: Union[Tensor, Number]) -> Tensor: ...
overload
def zeros_like___(self, value: Number, other: Union[Tensor, Number]) -> Tensor: ...
overload
def zeros_like___(self, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def zeros_like___(self, value: Number, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def zeros_like____(self, other: Union[Tensor, Number]) -> Tensor: ...
overload
def zeros_like____(self, value: Number, other: Union[Tensor, Number]) -> Tensor: ...
overload
def zeros_like____(self, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def zeros_like____(self, value: Number, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
# some codes here...
```
But `__init__.pyi` should generate these type hints.
```python
class Tensor:
# some codes here...
overload
def add_(self, other: Union[Tensor, Number]) -> Tensor: ...
overload
def add_(self, value: Number, other: Union[Tensor, Number]) -> Tensor: ...
overload
def add_(self, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def add_(self, value: Number, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
# some codes here...
overload
def div_(self, other: Union[Tensor, Number]) -> Tensor: ...
overload
def div_(self, value: Number, other: Union[Tensor, Number]) -> Tensor: ...
overload
def div_(self, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def div_(self, value: Number, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
# some codes here...
overload
def mul_(self, other: Union[Tensor, Number]) -> Tensor: ...
overload
def mul_(self, value: Number, other: Union[Tensor, Number]) -> Tensor: ...
overload
def mul_(self, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def mul_(self, value: Number, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
# some codes here...
overload
def sub_(self, other: Union[Tensor, Number]) -> Tensor: ...
overload
def sub_(self, value: Number, other: Union[Tensor, Number]) -> Tensor: ...
overload
def sub_(self, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
overload
def sub_(self, value: Number, other: Union[Tensor, Number], *, out: Optional[Tensor]=None) -> Tensor: ...
# some codes here...
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33748
Differential Revision: D20090444
Pulled By: ngimel
fbshipit-source-id: e4a5dd08126629ec4c54b630a87ee540e669ec9a