Repository: pytorch
Issue: [fx] tracing function with in-place mutation results in unexpected behaviour due to local vars becoming persisted in  `GraphModule(nn.Module)`
Labels: triaged,module: fx

### 🐛 Describe the bug

fx tracing a function which inplace updates some tensor that will be cached as a constant will give inconsistent results, as the cached constant gets mutated on each call to the fx graph:

```python
import torch

def fn(x):
    a = torch.ones((1,))
    return a.add_(x)

traced = torch.fx.symbolic_trace(fn)
x = torch.tensor([1.])
print(traced(x))  # tensor([2.])
print(traced(x))  # tensor([3.])
```

I get why this happens, and it probably isn't favourable to add overhead with `torch.clone`ing any constant. Unless we recognise when a tensor constant gets inplace updated in the graph, and only `torch.clone` a tensor constant in this case, as maybe some extra overhead is better than it not working properly in this case?

If not maybe just adding a small explanation of this to the miscallanea section of the fx docs would be helpful? I can make a pr if it helps



### Versions

PyTorch version: 2.0.1+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Debian GNU/Linux 10 (buster) (x86_64)
GCC version: (Debian 8.3.0-6) 8.3.0
Clang version: 7.0.1-8+deb10u2 (tags/RELEASE_701/final)
CMake version: Could not collect
Libc version: glibc-2.28

Python version: 3.10.0 (default, Mar  3 2022, 09:58:08) [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.15.0-1041-azure-x86_64-with-glibc2.28
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
Address sizes:       48 bits physical, 48 bits virtual
CPU(s):              16
On-line CPU(s) list: 0-15
Thread(s) per core:  2
Core(s) per socket:  8
Socket(s):           1
NUMA node(s):        1
Vendor ID:           AuthenticAMD
CPU family:          25
Model:               1
Model name:          AMD EPYC 7763 64-Core Processor
Stepping:            1
CPU MHz:             2445.431
BogoMIPS:            4890.86
Virtualization:      AMD-V
Hypervisor vendor:   Microsoft
Virtualization type: full
L1d cache:           32K
L1i cache:           32K
L2 cache:            512K
L3 cache:            32768K
NUMA node0 CPU(s):   0-15
Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl tsc_reliable nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy svm cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext invpcid_single vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr rdpru arat npt nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold v_vmsave_vmload umip vaes vpclmulqdq rdpid fsrm

Versions of relevant libraries:
[pip3] flake8==6.0.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.23.5
[pip3] torch==2.0.1+cpu
[pip3] torch-scatter==2.1.1
[conda] numpy                     1.24.0                   pypi_0    pypi

cc @ezyang @SherlockNoMad @EikanWang @jgong5 @wenzhe-nrv