Merge code for training tied and untied weights.
Allow sample trainer to be used for tied weights.