Some modules inside sequential modules need multiple inputs

Hello,
Let’s assume that I want to define a torch.nn.The sequential container in which some of its modules take some inputs other than input x. For example, if the sequential container is defined like this:

self.my_seq = torch.nn.Sequential(
module_A(),
module_B(),
module_C(),
)

Then in the forward method of the class, I want to pass some arguments for module_A and module_C other than input x, i.e.,

def forward(self, x, module_A_argument, module_C_argument):
self.my_seq(x, module_A_argument, module_C_argument)

where I would like it to do the following operation:
output = module_A(x, module_A_argument)
output = module_B(output)
ouput = module_C(output, module_C_argument)

How can I have this feature in sequential container?

Have a look at this topic with potential workarounds and links to further discussions and implementations. :slight_smile: