Repository: pytorch
Issue: `MultiLabelMarginLoss` will return incorrect values in JIT after the first run on cuda
Labels: oncall: jit,module: cuda,triaged,module: nvfuser

### 🐛 Describe the bug

`MultiLabelMarginLoss` will return incorrect values in JIT after the first run in some cases

```py
import torch

class M(torch.nn.Module):
    def __init__(self):
        super().__init__()
        loss = torch.nn.MultiLabelMarginLoss()
        inp1 = torch.empty([1, 4], dtype=torch.int64)
        inp1 = torch.randint_like(inp1, -32, 128).to('cuda')
        self.loss = loss
        self.inp1 = inp1

    def forward(self, inp):
        inp = torch.nn.functional.relu(inp)
        inp = torch.nn.functional.relu(inp)
        inp = torch.mul(inp, torch.tensor(13, dtype=torch.float32, device='cuda'))
        inp = torch.nn.functional.relu(inp)
        fn_res = self.loss(inp, self.inp1)
        fn_res = torch.sin(fn_res)
        return fn_res

torch.random.manual_seed(5100)
fn = M().to('cuda')

torch.random.manual_seed(5100)
inp = torch.empty([1, 4], dtype=torch.float32, memory_format=torch.contiguous_format)
inp.uniform_(-8, 15)

jit_fn = torch.jit.script(fn)

print('normal function')
for _ in range(3):
    print(fn(inp.clone().to('cuda'), ))

print('jitted function')
for _ in range(3):
    print(jit_fn(inp.clone().to('cuda'), ))
```

```
normal function
tensor(0.1331, device='cuda:0')
tensor(0.1331, device='cuda:0')
tensor(0.1331, device='cuda:0')
jitted function
tensor(0.1331, device='cuda:0')
tensor(-0.7621, device='cuda:0')
tensor(-0.7621, device='cuda:0')
```

---

Besides, `resize_as_` also suffers from this issue

```py
import torch

class M(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, _input_tensor, tensor):
        tensor = torch.nn.functional.tanhshrink(tensor)
        fn_res = _input_tensor.resize_as_(tensor, )
        fn_res = torch.nn.functional.relu(fn_res)
        fn_res = torch.mul(fn_res, torch.tensor(-2, dtype=torch.float32, device='cuda'))
        return fn_res

fn = M().to('cuda')

torch.random.manual_seed(31029)
inp = torch.empty([], dtype=torch.float64, memory_format=torch.contiguous_format)
inp.uniform_(-2, 1)
t = torch.empty([5], dtype=torch.float64, memory_format=torch.contiguous_format)
t.uniform_(-8, 31)

jit_fn = torch.jit.script(fn)

print('normal function')
for _ in range(3):
    print(fn(inp.clone().to('cuda'), t.clone().to('cuda')))

print('jitted function')
for _ in range(3):
    print(jit_fn(inp.clone().to('cuda'), t.clone().to('cuda')))
```

```
normal function
tensor([-0.9099, -2.0000, -2.0000, -2.0000, -2.0000], device='cuda:0',
       dtype=torch.float64)
tensor([-0.9099, -2.0000, -2.0000, -2.0000, -2.0000], device='cuda:0',
       dtype=torch.float64)
tensor([-0.9099, -2.0000, -2.0000, -2.0000, -2.0000], device='cuda:0',
       dtype=torch.float64)
jitted function
tensor([-0.9099, -2.0000, -2.0000, -2.0000, -2.0000], device='cuda:0',
       dtype=torch.float64)
tensor([-0.9099, -0.0000, -0.0000, -0.0000, -0.0000], device='cuda:0',
       dtype=torch.float64)
tensor([-0.9099, -0.0000, -0.0000, -0.0000, -0.0000], device='cuda:0',
       dtype=torch.float64)
```

### Versions

```
PyTorch version: 1.13.0.dev20221001
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.1 LTS (x86_64)
GCC version: (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.35

Python version: 3.9.13 (main, Aug 25 2022, 23:26:10)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.19.5-051905-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.7.99
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3060
Nvidia driver version: 515.65.01
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.23.3
[pip3] torch==1.13.0.dev20221001
[pip3] torchaudio==0.13.0.dev20221001
[pip3] torchvision==0.14.0.dev20221001
[conda] blas                      1.0                         mkl  
[conda] mkl                       2021.4.0           h06a4308_640  
[conda] mkl-service               2.4.0            py39h7f8727e_0  
[conda] mkl_fft                   1.3.1            py39hd3c417c_0  
[conda] mkl_random                1.2.2            py39h51133e4_0  
[conda] numpy                     1.23.3                   pypi_0    pypi
[conda] numpy-base                1.23.1           py39ha15fc14_0  
[conda] pytorch                   1.13.0.dev20221001 py3.9_cuda11.7_cudnn8.5.0_0    pytorch-nightly
[conda] pytorch-cuda              11.7                 h67b0de4_0    pytorch-nightly
[conda] pytorch-mutex             1.0                        cuda    pytorch-nightly
[conda] torch                     1.13.0.dev20220923+cu116          pypi_0    pypi
[conda] torchaudio                0.13.0.dev20220923+cu116          pypi_0    pypi
[conda] torchvision               0.14.0.dev20220923+cu116          pypi_0    pypi
```

cc @ngimel