Repository: pytorch
Issue: `atan2` will gradcheck fail when `other` is a tensor with `int8` dtype
Labels: module: autograd,triaged,module: edge cases

### 🐛 Describe the bug

`atan2` will gradcheck fail when `other` is a tensor with `int8` dtype

```python
import torch

def fn(input):
    other = torch.tensor([[22, 18, 29, 24, 27],
        [ 3, 11, 23,  1, 19],
        [17, 26, 11, 26,  2],
        [22, 11, 21, 23, 29],
        [ 7, 30, 24, 15, 10]], dtype=torch.int8)
    fn_res = torch.atan2(input, other, )
    return fn_res

input = torch.tensor([[ 0.6021, -0.8055, -0.5270, -0.3233, -0.9129]], dtype=torch.float64, requires_grad=True)
torch.autograd.gradcheck(fn, (input))
```

It will fail

```
GradcheckError: Jacobian mismatch for output 0 with respect to input 0,
numerical:tensor([[0.0454, 0.0000, 0.0000, 0.0000, 0.0000, 0.3204, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0587, 0.0000, 0.0000, 0.0000, 0.0000, 0.0454, 0.0000, 0.0000,
         0.0000, 0.0000, 0.1418, 0.0000, 0.0000, 0.0000, 0.0000],
        [0.0000, 0.0554, 0.0000, 0.0000, 0.0000, 0.0000, 0.0904, 0.0000, 0.0000,
         0.0000, 0.0000, 0.0384, 0.0000, 0.0000, 0.0000, 0.0000, 0.0904, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0333, 0.0000, 0.0000, 0.0000],
        [0.0000, 0.0000, 0.0345, 0.0000, 0.0000, 0.0000, 0.0000, 0.0435, 0.0000,
         0.0000, 0.0000, 0.0000, 0.0907, 0.0000, 0.0000, 0.0000, 0.0000, 0.0476,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0416, 0.0000, 0.0000],
        [0.0000, 0.0000, 0.0000, 0.0417, 0.0000, 0.0000, 0.0000, 0.0000, 0.9054,
         0.0000, 0.0000, 0.0000, 0.0000, 0.0385, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0435, 0.0000, 0.0000, 0.0000, 0.0000, 0.0666, 0.0000],
        [0.0000, 0.0000, 0.0000, 0.0000, 0.0370, 0.0000, 0.0000, 0.0000, 0.0000,
         0.0525, 0.0000, 0.0000, 0.0000, 0.0000, 0.4138, 0.0000, 0.0000, 0.0000,
         0.0000, 0.0344, 0.0000, 0.0000, 0.0000, 0.0000, 0.0992]],
       dtype=torch.float64)
analytical:tensor([[-0.7960,  0.0000,  0.0000,  0.0000,  0.0000,  0.3204,  0.0000,  0.0000,
          0.0000,  0.0000,  0.5096,  0.0000,  0.0000,  0.0000,  0.0000, -0.7960,
          0.0000,  0.0000,  0.0000,  0.0000,  0.1418,  0.0000,  0.0000,  0.0000,
          0.0000],
        [ 0.0000,  0.2622,  0.0000,  0.0000,  0.0000,  0.0000,  0.0904,  0.0000,
          0.0000,  0.0000,  0.0000, -0.2846,  0.0000,  0.0000,  0.0000,  0.0000,
          0.0904,  0.0000,  0.0000,  0.0000,  0.0000, -0.2432,  0.0000,  0.0000,
          0.0000],
        [ 0.0000,  0.0000,  0.3958,  0.0000,  0.0000,  0.0000,  0.0000,  1.3312,
          0.0000,  0.0000,  0.0000,  0.0000,  0.0907,  0.0000,  0.0000,  0.0000,
          0.0000, -0.2969,  0.0000,  0.0000,  0.0000,  0.0000,  0.3734,  0.0000,
          0.0000],
        [ 0.0000,  0.0000,  0.0000,  0.3744,  0.0000,  0.0000,  0.0000,  0.0000,
          0.9054,  0.0000,  0.0000,  0.0000,  0.0000, -0.2829,  0.0000,  0.0000,
          0.0000,  0.0000,  1.3447,  0.0000,  0.0000,  0.0000,  0.0000, -0.4855,
          0.0000],
        [ 0.0000,  0.0000,  0.0000,  0.0000, -0.7074,  0.0000,  0.0000,  0.0000,
          0.0000,  0.1795,  0.0000,  0.0000,  0.0000,  0.0000,  0.4138,  0.0000,
          0.0000,  0.0000,  0.0000,  0.3928,  0.0000,  0.0000,  0.0000,  0.0000,
          0.0992]], dtype=torch.float64)
```

But when the `other` is `int16` or `int32`, it will pass the gradcheck

```python
import torch

def fn(input):
    other = torch.tensor([[22, 18, 29, 24, 27],
        [ 3, 11, 23,  1, 19],
        [17, 26, 11, 26,  2],
        [22, 11, 21, 23, 29],
        [ 7, 30, 24, 15, 10]], dtype=torch.int16)
    fn_res = torch.atan2(input, other, )
    return fn_res

input = torch.tensor([[ 0.6021, -0.8055, -0.5270, -0.3233, -0.9129]], dtype=torch.float64, requires_grad=True)
torch.autograd.gradcheck(fn, (input))
# True
```

### Versions

pytorch: 1.11.0

cc @ezyang @albanD @zou3519 @gqchen @pearu @nikitaved @soulitzer @Lezcano @Varal7