The error seems to point to another place in the code no? You need to make sure not to unpack too many values.
Also for torch.zeros(1).to(gf.device).double(), you can replace it with torch.zeros(1, device=gf.device, dtype=torch.double).