Your code is quite complicated to debug.
Could you provide some dummy tensors and all other necessary parameters, so that I would debug it on my machine?
As a starter, could you remove the inplace argument in x = F.relu(v(x), inplace=True)?