torch.jit.script ERR: RuntimeError: Can't redefine method: forward on class: __torch__.SoSadModule
Labels: oncall: jit

### 🐛 Describe the bug

I used storch.jit.script to script my model, but got some err. This is fine . But I continue script its sub module.  I got an err "RuntimeError: Can't redefine method: forward on class: __torch__.SoSadModule (of Python compilation unit at: 0x530d560)"

the simple code is following, this is my nn.Module:

```
import torch
from torch import nn


class SoSadModule(nn.Module):
    def __init__(self,):
        nn.Module.__init__(self)
    
    def forward(self, x):
        return nn.Softmax(x)


class SadModule(nn.Module):
    def __init__(self, use_skip: bool):
        nn.Module.__init__(self)
        self.use_skip = use_skip
        self.layer = nn.Linear(2, 2)
        self.layer_softmax = SoSadModule()

    def forward(self, x):
        if self.use_skip:
            x_input = x
        x = self.layer(x)
        if self.use_skip:
            x = x + x_input
        self.layer_softmax(x)
        return x

```
and i run code:
```
model = SadModule(False)
try:
    torch.jit.script(model)
except:
    pass
torch.jit.script(model.layer_softmax)

```
i got message that I didn't expect.

```
Traceback (most recent call last):
  File "pr.py", line 38, in <module>
    torch.jit.script(model.layer_softmax)
  File "/home/disk2/users/chenfuyuan/icode/project_repository/cont_time_classify/torch/jit/_script.py", line 1286, in script
    return torch.jit._recursive.create_script_module(
  File "/home/disk2/users/chenfuyuan/icode/project_repository/cont_time_classify/torch/jit/_recursive.py", line 480, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "/home/disk2/users/chenfuyuan/icode/project_repository/cont_time_classify/torch/jit/_recursive.py", line 546, in create_script_module_impl
    create_methods_and_properties_from_stubs(concrete_type, method_stubs, property_stubs)
  File "/home/disk2/users/chenfuyuan/icode/project_repository/cont_time_classify/torch/jit/_recursive.py", line 397, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(property_defs, property_rcbs, method_defs, method_rcbs, method_defaults)
RuntimeError: Can't redefine method: forward on class: __torch__.SoSadModule (of Python compilation unit at: 0x3f45600)
```

If i script sub module of it directly, like this.

```
model = SadModule(False)
# try:
#     script_model = torch.jit.script(model)
# except:
#     pass
torch.jit.script(model.layer_softmax)
```

 I got err that i expected , where is not supported by script.

```
Traceback (most recent call last):
  File "pr.py", line 38, in <module>
    torch.jit.script(model.layer_softmax)
  File "/home/disk2/users/chenfuyuan/icode/project_repository/cont_time_classify/torch/jit/_script.py", line 1286, in script
    return torch.jit._recursive.create_script_module(
  File "/home/disk2/users/chenfuyuan/icode/project_repository/cont_time_classify/torch/jit/_recursive.py", line 480, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "/home/disk2/users/chenfuyuan/icode/project_repository/cont_time_classify/torch/jit/_recursive.py", line 546, in create_script_module_impl
    create_methods_and_properties_from_stubs(concrete_type, method_stubs, property_stubs)
  File "/home/disk2/users/chenfuyuan/icode/project_repository/cont_time_classify/torch/jit/_recursive.py", line 397, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(property_defs, property_rcbs, method_defs, method_rcbs, method_defaults)
  File "/home/disk2/users/chenfuyuan/icode/project_repository/cont_time_classify/torch/jit/annotations.py", line 142, in check_fn
    raise torch.jit.frontend.FrontendError(
torch.jit.frontend.FrontendError: Cannot instantiate class 'Softmax' in a script function:
  File "pr.py", line 14
    def forward(self, x):
        return nn.Softmax(x)
               ~~~~~~~~~~ <--- HERE
```

JIT have affect my model? or there are some API to close this ill effects, so i can JIT a model multiple times with no err " redefine method: forward on class: __torch__.SoSadModule "


### Versions

pytorch: 1.9.1 and pytorch: 2.0.0.dev and all version of pytorch now.

cc @EikanWang @jgong5 @wenzhe-nrv @sanchitintel