I’m not sure, what your exact use case is, but the last RuntimeError could be raised, if whh and ht_1 both require gradients, as they are reused in the second iteration.
You could detach ht_1, if it fits your use case:
ht=torch.tanh(whh.mm(ht_1.detach())+wxt.mm(inp.float()))