There are at least a couple of ways to add a module to your model…


model.name = module automagically adds the module
model.add_module(name, module)

Your code does neither for generators, so therefore generators isn’t added to your model, which as you say, is the source of your problem. You could apply either of the above suggestions, but might I suggest the following cleaner possibility?
generators = nn.ModuleList() # behaves like a python list, but adds its elements to the model.
for i in range(n):
    main = nn.Sequential()
    main.add_module("some_module", some_module)
    generators.append(main)

N.B. nn.ModuleList doesn’t have a .forward method, so you will need to loop over its contents in your model’s .forward method.
Your example code adds several modules of the same name to main. Does this work as expected?
I would have done main.add_module("some_module_"+str(i), some_module) to avoid any ambiguities.
Besides if you don’t need to name the submodules the following one-liner should work just as well.
generators.append(nn.Sequential(*[some_module for i in range(n)]))