The model definition does not seem to be complete. However, you can simply add the mentioned modules to the nn.ModuleList
and iterate it. Something like this should work:
modules = nn.ModuleList([
nn.Linear(..., 19),
nn.ReLU(),
...
])
for module in modules:
x = module(x)