Repository: pytorch
Issue: [NvFuser] INTERNAL ASSERT FAIL "ScalarType should be static for Tensors in fusion for amp optimization"
Labels: triaged,module: assert failure,module: nvfuser

### 🐛 Describe the bug

[NvFuser] INTERNAL ASSERT FAIL "ScalarType should be static for Tensors in fusion for amp optimization" with multiple nested if-contidions

```py
import torch

class M(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, input):
        input_1 = input
        # bug cause
        if input.dtype == torch.bfloat16:
            input_1 = torch.nn.functional.tanhshrink(input)
            if input_1.dtype == torch.int8:
                if input_1.dtype == torch.complex64:
                    input.cos_()
        input_1 = torch.mul(input, torch.tensor(-13, dtype=torch.float32, device='cuda'))
        input = input_1
        fn_res = torch.deg2rad(input, )
        return fn_res

fn = M().to('cuda')
torch.random.manual_seed(65358)
input_tensor = torch.empty([3, 2], dtype=torch.float32, memory_format=torch.contiguous_format)
input_tensor.uniform_(-64, 1)
inp = input_tensor.to('cuda')

jit_fn = torch.jit.script(fn)

for i in range(5):
    print(i)
    jit_fn(inp)
```

```
0
1

RuntimeError: scalar_type.has_value() INTERNAL ASSERT FAILED at "/opt/conda/conda-bld/pytorch_1659484809662/work/torch/csrc/jit/codegen/cuda/graph_fuser.cpp":1938, please report a bug to PyTorch. ScalarType should be static for Tensors in fusion for amp optimization
```

### Versions

```
Collecting environment information...
PyTorch version: 1.12.1
Is debug build: False
CUDA used to build PyTorch: 11.3
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: 14.0.0-1ubuntu1
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] functorch==0.2.1
[pip3] numpy==1.23.3
[pip3] torch==1.13.0.dev20220923+cu116
[pip3] torchaudio==0.13.0.dev20220923+cu116
[pip3] torchvision==0.14.0.dev20220923+cu116
[conda] _tflow_select             2.3.0                       mkl  
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.3.1               h2bc3f7f_2  
[conda] functorch                 0.2.1                    pypi_0    pypi
[conda] libblas                   3.9.0            12_linux64_mkl    conda-forge
[conda] libcblas                  3.9.0            12_linux64_mkl    conda-forge
[conda] liblapack                 3.9.0            12_linux64_mkl    conda-forge
[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.12.1          py3.9_cuda11.3_cudnn8.3.2_0    pytorch
[conda] pytorch-cuda              11.7                 h67b0de4_0    pytorch-nightly
[conda] pytorch-mutex             1.0                        cuda    pytorch-nightly
[conda] tensorflow-base           2.9.1           mkl_py39h353358b_0  
[conda] torch                     1.12.1                   pypi_0    pypi
[conda] torchaudio                0.13.0.dev20220923+cu116          pypi_0    pypi
[conda] torchvision               0.14.0.dev20220923+cu116          pypi_0    pypi
```