[JIT] Inconsistency  in tensor shape between eager mode and JIT
Labels: oncall: jit

### 🐛 Describe the bug

When the inplace operator `unsqueeze_` is used after `expand`, the program behavior in JIT differs from that in eager mode. Here's a minimal reproduction:
```python
import torch

def fn(input):
    v = torch.Tensor.expand(input, [2, 2, 3])
    torch.Tensor.unsqueeze_(input, dim=-1) # works with non-inplace version "unsqueeze"
    return v

x = torch.rand([2, 1, 3])
fn(x)
print("Eager mode ... OK!")
traced_fn = torch.jit.trace(fn, x)
print("JIT ... OK!")

"""
Eager mode ... OK!
Traceback (most recent call last):
  File "model.py", line 11, in <module>
    traced_fn = torch.jit.trace(fn, x)
  File "python3.10/site-packages/torch/jit/_trace.py", line 856, in trace
    traced = torch._C._create_function_from_trace(
  File "model.py", line 4, in fn
    v = torch.Tensor.expand(input, [2, 2, 3])
RuntimeError: expand(torch.FloatTensor{[2, 1, 3, 1]}, size=[2, 2, 3]): the number of sizes 
provided (3) must be greater or equal to the number of dimensions in the tensor (4)
"""
```

Although `torch.Tensor.unsqueeze_` is an in-place operator, it appears after `torch.Tensor.expand` and it shouldn't have impact on the shape of `input`. In jit it seems that there's something wrong with the execution order.

### Versions

<details><summary> <b>Environment</b> <i> [click to expand] </i> </summary>

```
PyTorch version: 1.14.0a0+gitbdc9911
Is debug build: False
CUDA used to build PyTorch: 11.6
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.1 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Clang version: 11.1.0-6
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] (64-bit runtime)
Python platform: Linux-5.15.0-56-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.6.124
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 3090
GPU 1: NVIDIA GeForce RTX 3090
GPU 2: NVIDIA GeForce RTX 3090

Nvidia driver version: 515.86.01
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.4.1
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] numpy==1.21.5
[pip3] torch==1.14.0a0+gitbdc9911
[conda] blas                      1.0                         mkl  
[conda] cudatoolkit               11.3.1               h2bc3f7f_2  
[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.21.5           py39he7a7128_1  
[conda] numpy-base                1.21.5           py39hf524024_1  
[conda] numpydoc                  1.2                pyhd3eb1b0_0  
[conda] torch                     1.14.0a0+gitce2f870          pypi_0    pypi
```
</details>

cc @EikanWang @jgong5 @wenzhe-nrv @sanchitintel