What you can do is to define a BaseNet which impelments the forward pass
class BaseNet(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
    def forward(self, x):
        x = x.view(-1, 10)
        x = F.relu(self.fc1(x))
        x = self.fc3(x)
        return x

Later on, for each network you can define the network from kwargs inheriting the one which implements the forward Like:
class Net(BaseNet):
    def __init__(self,**kwargs):
        super(Net, self).__init__()
        for key, values in kwargs.items():
            setattr(self,key,nn.Linear(*values))
kwargs = {'fc1':[10,5,False],'fc2':[5,2,False]}
model = Net(**kwargs)

It’s a matter of playing around how to pass arguments to build the network in the init, plenty of ways of doing it.