Is different modules of different number of inputs impossible with `nn.Sequential`?

Consider the following code

import torch
import torch.nn as nn
from collections import OrderedDict

class sum_t(nn.Module):
  def __init__(self):
  def forward(self, x, y):
    return x + y

model = nn.Sequential(OrderedDict([
          ('conv1', nn.Conv2d(3, 3, 1)),
          ('relu1', nn.ReLU()),
          ('conv2', nn.Conv2d(3, 3, 1)),
          ('relu2', nn.ReLU()),
          ('sum0', sum_t()),
          ('sum1', sum_t())

x = torch.randn(3, 3, 64, 64)
y = torch.randn(3, 3, 64, 64)

I want to pass two inputs x, y to the last two modules only, but one input x to the first four layers. Is it possible to do with nn.Sequential? How can I do model(x,y)?

If possible, I want to do it so that I can use the code from PyTorch and hook my codes.

nn.Sequental won’t accept multiple inputs by default, but a few workarounds are posted in this topic with links to GitHub issues with more suggestions.
If these custom nn.Sequential modifications don’t fit into your use case, I would recommend to write a custom nn.Module and define the forward method explicitly using both inputs.