If what you want is only the list without links. There is a hack way.
import torch
import importlib
import sys


def traversedir(module, pref=''):
    for attr in dir(module):
        if attr[0] == '_':
            continue
        if attr not in sys.modules:
            fullname = f'{pref}.{attr}'
            yield fullname
            try:
                importlib.import_module(fullname)
                for submodule in traversedir(getattr(module, attr), pref=fullname):
                    yield submodule
            except:
                continue


if __name__ == "__main__":
    for x in traversedir(torch, pref='torch'):
        print(x)