To me, mixed approach looks better.
For the record, I have updated the gist to verify that it works too.

  
      gist.github.com
  
  
    https://gist.github.com/InnovArul/500e0c57e88300651f8005f9bd0d12bc 427
tied_linear.py
import torch, torch.nn as nn, torch.nn.functional as F
import numpy as np
import torch.optim as optim

# tied autoencoder using off the shelf nn modules
class TiedAutoEncoderOffTheShelf(nn.Module):
    def __init__(self, inp, out, weight):
        super().__init__()
        self.encoder = nn.Linear(inp, out, bias=False)
        self.decoder = nn.Linear(out, inp, bias=False)
This file has been truncated. show original