Repository: pytorch
Issue: [jit] ignored method calling static method results in an error
Labels: oncall: jit

### 🐛 Describe the bug

```py
In [7]: class M(torch.nn.Module):
   ...:     @staticmethod
   ...:     def static(self):
   ...:         return 1
   ...:
   ...:     @torch.jit.ignore
   ...:     def ignored(self):
   ...:         return self.static()
   ...:     def forward(self):
   ...:         return self.ignored()
   ...:

In [8]: m = torch.jit.script(M())

In [9]: m
Out[9]: RecursiveScriptModule(original_name=M)

In [10]: m()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 m()

File ~/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py:1186, in Module._call_impl(self, *input, **kwargs)
   1182 # If we don't have any hooks, we want to skip the rest of the logic in
   1183 # this function, and just call forward.
   1184 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1185         or _global_forward_hooks or _global_forward_pre_hooks):
-> 1186     return forward_call(*input, **kwargs)
   1187 # Do not call functions when jit is used
   1188 full_backward_hooks, non_full_backward_hooks = [], []

RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
  File "<ipython-input-7-176d8289088f>", line 10, in forward
    def forward(self):
        return self.ignored()
               ~~~~~~~~~~~~ <--- HERE
RuntimeError: AttributeError: 'RecursiveScriptModule' object has no attribute 'static'

At:
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py(1261): __getattr__
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/torch/jit/_script.py(502): __getattr__
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/torch/jit/_script.py(785): __getattr__
  <ipython-input-7-176d8289088f>(8): ignored
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/torch/jit/_recursive.py(921): lazy_binding_method
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/torch/nn/modules/module.py(1186): _call_impl
  <ipython-input-10-ec2213f3535c>(1): <cell line: 1>
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/IPython/core/interactiveshell.py(3361): run_code
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/IPython/core/interactiveshell.py(3301): run_ast_nodes
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/IPython/core/interactiveshell.py(3098): run_cell_async
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/IPython/core/async_helpers.py(129): _pseudo_sync_runner
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/IPython/core/interactiveshell.py(2900): _run_cell
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/IPython/core/interactiveshell.py(2854): run_cell
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py(646): interact
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/IPython/terminal/interactiveshell.py(653): mainloop
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/IPython/terminal/ipapp.py(318): start
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/traitlets/config/application.py(846): launch_instance
  /Users/S_sn/miniconda3/lib/python3.8/site-packages/IPython/__init__.py(123): start_ipython
  /Users/S_sn/miniconda3/bin/ipython(11): <module>

```

### Versions

```
PyTorch version: 1.13.0.dev20220805
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 12.3 (arm64)
GCC version: Could not collect
Clang version: 13.1.6 (clang-1316.0.21.2.5)
CMake version: version 3.20.1
Libc version: N/A

Python version: 3.8.11 (default, Jul 29 2021, 14:57:32)  [Clang 12.0.0 ] (64-bit runtime)
Python platform: macOS-12.3-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
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

Versions of relevant libraries:
[pip3] functorch==0.3.0a0+012d5a2
[pip3] mypy==0.950
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.2
[pip3] torch==1.13.0.dev20220805
[pip3] torchaudio==0.11.0
[pip3] torchdynamo==1.13.0.dev0
[pip3] torchfile==0.1.0
[pip3] torchvision==0.13.0
[conda] numpy                     1.21.2           py38hb38b75b_0
[conda] numpy-base                1.21.2           py38h6269429_0
[conda] torch                     1.13.0.dev20220805          pypi_0    pypi
[conda] torchaudio                0.11.0                   pypi_0    pypi
[conda] torchdynamo               1.13.0.dev0              pypi_0    pypi
[conda] torchfile                 0.1.0                    pypi_0    pypi
[conda] torchvision               0.13.0                   pypi_0    pypi

```