How would you build a lightweight version of PyTorch from scratch, including autograd and backpropagation?