How to create and train a tied autoencoder?

If you want to you can also have two modules that share a weight matrix just by setting mod1.weight = mod2.weight, but the functional approach is likely to be less magical and harder to make a mistake with.