Couldn’t you do this?

image.png1715×383 17.3 KB

Using nn.Sequential with an OrderedDict from collections is a good way to organized named Modules ahead of time and then construct the actual nn graph at run time.