Parallel two encoder in Pytorch

I have an encoder class that is defined in a class in PyTorch. I want to use this model for two parallel models as follows. could you help me to solve that?

class  Encoder(nn.Module):

model 1

optimizer        = torch.optim.Adam(model1.parameters(), lr=6e-4)
losses = train(model1, device, 100, data1, optimizer)


model2           = Encoder(100,  1,   2,  10, device).to(device)
optimizer        = torch.optim.Adam(model2.parameters(), lr=6e-4)
losses = train(model2, device, 100, data2, optimizer)

Here is the figure which I want:

You could use the two models in a new custom nn.Module, execute both forward passes, and concatenate the output.
This post was written for a slightly different use case, but might be a good starter.