Although the program is running without errors, the result is not intended one. Got stuck for the past two days. Any help will be greatly appreciated.

```
optimizer_G.zero_grad()
for res_idx in range(2):
a = someloss
b = someloss
c = someloss
d = someloss
if res_idx is 0:
loss_G = a + b + c + d
else:
loss_G += a + b + c + d
loss_G.backward()
optimizer_G.step()
```

The losses a, b, c, d changes as loop continues. Is this the correct way to define the loss (since loss parameters are overwritten) and updating the parameters?