Torch 1.13 Onnx Scope constant name not correct!
Labels: module: onnx, triaged

### 🐛 Describe the bug

i'm using the pytorch 1.13 to convert the stable diffusion unet to onnx model. and i noticed that torch 1.13 will preserve the original module name in onnx graph.but it seems the constant name is not always corresponding to the state_dict weights name in torch.like some weights name in torch state_dict are :
```python
down_blocks.1.attentions.1.transformer_blocks.0.ff.net.0.proj.weight 

down_blocks.1.attentions.1.transformer_blocks.0.ff.net.0.proj.bias
```
in onnx,there is no constant data named down_blocks.1.attentions.1.transformer_blocks.0.ff.net.0.proj.weight,but there is constant data named down_blocks.1.attentions.1.transformer_blocks.0.ff.net.0.proj.bias. the nodes corresponding to down_blocks.1.attentions.1.transformer_blocks.0.ff.net.0.proj in onnx are:
```python
/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/Cast (Cast)
        Inputs: [
                Variable (/down_blocks.1/attentions.1/transformer_blocks.0/norm3/LayerNormalization_output_0): (shape=['2B', '(floor(H/2 - 1/2) + 1)*(floor(W/2 - 1/2) + 1)', 640], dtype=float32)
        ]
        Outputs: [
                Variable (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/Cast_output_0): (shape=['2B', '(floor(H/2 - 1/2) + 1)*(floor(W/2 - 1/2) + 1)', 640], dtype=float16)
        ]
Attributes: OrderedDict([('to', 10)])
/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/MatMul (MatMul)
        Inputs: [
                Variable (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/Cast_output_0): (shape=['2B', '(floor(H/2 - 1/2) + 1)*(floor(W/2 - 1/2) + 1)', 640], dtype=float16)
                Constant (onnx::MatMul_9242): (shape=[640, 5120], dtype=float16)
        ]
        Outputs: [
                Variable (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/MatMul_output_0): (shape=['2B', '(floor(H/2 - 1/2) + 1)*(floor(W/2 - 1/2) + 1)', 5120], dtype=float16)
        ]
/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/Add (Add)
        Inputs: [
                Constant (down_blocks.1.attentions.1.transformer_blocks.0.ff.net.0.proj.bias): (shape=[5120], dtype=float16)
                Variable (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/MatMul_output_0): (shape=['2B', '(floor(H/2 - 1/2) + 1)*(floor(W/2 - 1/2) + 1)', 5120], dtype=float16)
        ]
        Outputs: [
                Variable (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/Add_output_0): (shape=['2B', '(floor(H/2 - 1/2) + 1)*(floor(W/2 - 1/2) + 1)', 5120], dtype=float16)
        ]
/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/Slice (Slice)
        Inputs: [
                Variable (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/Add_output_0): (shape=['2B', '(floor(H/2 - 1/2) + 1)*(floor(W/2 - 1/2) + 1)', 5120], dtype=float16)
                Constant (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/Constant_1_output_0): (shape=[1], dtype=int64)
                Constant (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/Mul_output_0): (shape=[1], dtype=int64)
                Constant (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/Constant_output_0): (shape=[1], dtype=int64)
        ]
        Outputs: [
                Variable (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/Slice_output_0): (shape=['2B', '(floor(H/2 - 1/2) + 1)*(floor(W/2 - 1/2) + 1)', 2560], dtype=float16)
        ]
/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/Slice_1 (Slice)
        Inputs: [
                Variable (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/Add_output_0): (shape=['2B', '(floor(H/2 - 1/2) + 1)*(floor(W/2 - 1/2) + 1)', 5120], dtype=float16)
                Constant (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/Mul_output_0): (shape=[1], dtype=int64)
                Constant (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/Mul_1_output_0): (shape=[1], dtype=int64)
                Constant (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/Constant_output_0): (shape=[1], dtype=int64)
        ]
        Outputs: [
                Variable (/down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/Slice_1_output_0): (shape=['2B', '(floor(H/2 - 1/2) + 1)*(floor(W/2 - 1/2) + 1)', 2560], dtype=float16)
        ]
```

so, should /down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/MatMul (MatMul) node constant data's name be down_blocks.1.attentions.1.transformer_blocks.0.ff.net.0.proj.weight ,howerver it actually is onnx::MatMul_9242. But the bias is correct in /down_blocks.1/attentions.1/transformer_blocks.0/ff/net.0/proj/Add (Add) node .why does it happen?

### Versions

pytorch verison 1.13.1