I cannot debug the code as it’s not executable, but you should check these operations:
t[i,time_idx+1]=t[i,time_idx]+Time_res+ torch.sum(torch.dot(self.network_output[i,:], diff))

sumerror[i]=torch.log(torch.tensor(2+time_idx))*error

Nodein[b,:]=Node

as they are all assigning tensors inplace and try to replace them with a new tensor creation, if possible.