Repository: pytorch
Issue: `.modules()` is not callable in TorchScript when any submodule is a module interface type (i.e. a class decorated by `@torch.jit.interface`)
Labels: oncall: jit

## 🐛 Bug

`.modules()` is not callable in TorchScript when any submodule is a module interface type (i.e. a class decorated by `@torch.jit.interface`).

## To Reproduce

```python
import torch

@torch.jit.interface
class EmbeddingBagIf(torch.nn.Module):
    def forward(self, input: torch.Tensor) -> torch.Tensor:
        pass

class EmbeddingBagDummyImpl(torch.nn.Module):
    def __init__(self) -> None:
        super().__init__()

    def forward(self, input: torch.Tensor) -> torch.Tensor:
        return torch.tensor(1)

class EmbeddingBagProxy(torch.nn.Module):
    impl: EmbeddingBagIf

    def __init__(self) -> None:
        super().__init__()
        self.impl = EmbeddingBagDummyImpl()

    def forward(self, input: torch.Tensor) -> torch.Tensor:
        return torch.tensor(1)

class DPER3Module(torch.nn.Module):
    def __init__(self) -> None:
        super().__init__()

    @torch.jit.export
    def some_func(self):
        for module in self.modules():  # QUESTION: Can this work?
            print(module)

class EmbeddingPooling(DPER3Module):
    def __init__(self):
        super().__init__()
        self.proxy_embedding_bag = EmbeddingBagProxy()

    def forward(self, input: torch.Tensor) -> torch.Tensor:
        return torch.tensor(1)

m = EmbeddingPooling()
sm = torch.jit.script(m)
```
Gives error:
```
Traceback (most recent call last):
  File "test_yf225.py", line 43, in <module>
    sm = torch.jit.script(m)
  File "/data/miniconda3/envs/master_nightly/lib/python3.7/site-packages/torch/jit/_script.py", line 912, in script
    obj, torch.jit._recursive.infer_methods_to_compile
  File "/data/miniconda3/envs/master_nightly/lib/python3.7/site-packages/torch/jit/_recursive.py", line 370, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "/data/miniconda3/envs/master_nightly/lib/python3.7/site-packages/torch/jit/_recursive.py", line 430, in create_script_module_impl
    create_methods_and_properties_from_stubs(concrete_type, method_stubs, property_stubs)
  File "/data/miniconda3/envs/master_nightly/lib/python3.7/site-packages/torch/jit/_recursive.py", line 322, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(property_defs, property_rcbs, method_defs, method_rcbs, method_defaults)
RuntimeError: 
Could not compile modules() because module is an interface type. Please file issue.:
  File "test_yf225.py", line 31
    @torch.jit.export
    def some_func(self):
        for module in self.modules():  # QUESTION: can this work?
                      ~~~~~~~~~~~~ <--- HERE
            print(module)
```

## Expected behavior

`.modules()` unrolling in TorchScript should skip module interface types (since they don't have submodules), to make `.modules()` in TorchScript always work.

## Additional context

This is blocking the DPER-PyTorch compatibility work and creates a lot of friction in PyPer and TorchRec efforts.

cc. @SplitInfinity 

cc @gmagogsfm