Hi,
I don’t know if it is a good way of doing it, but it was working for my simple usage (note that all my models I use in it have *args ,**kwargs in their forward definition to allow other layers to use the additional arguments):
from torch import nn


class CombineModel(nn.Sequential):
    """ Class to combine multiple models. Sequential allowing multiple inputs."""

    def __init__(self, *args):
        super(CombineModel, self).__init__(*args)

    def forward(self, x, *args, **kwargs):
        for i, module in enumerate(self):
            if i == 0:
                x = module(x, *args, **kwargs)
            else:
                x = module(*x, **kwargs)
            if not isinstance(x, tuple) and i != len(self) - 1:
                x = (x,)
        return x

I’d be interested in your opinion, please let me know if I’m doing something completely wrong or unusable.