Thank you so much for the time you have taken out to write all the code and I appreciate it a lot. The question, I still have it is that why doesn’t my code calculates the gradients. Why the code written below works while they way i wrote didn’t especially when the policy loss is same for both of them. Thank you
multiply rewards with saved log_probs (tensors) to use their gradient path
for idx, _reward in enumerate(returns):
    policy_loss.append(_reward*model.saved_log_probs[idx])