code: def retrace(self, rewards, dones, q_values, state_values, rho, final_values):
          
          rho_bar = torch.min(torch.ones_like(rho) * self.retrace_rho_cap, rho)
  
          q_retraced_buffer = torch.zeros_like(rewards)
  
          next_value = final_values
  
          for i in reversed(range(rewards.size(0))):
              q_retraced = rewards[i] + self.discount_factor * next_value * (1.0 - dones[i])
  
              # Next iteration
              next_value = rho_bar[i] * (q_retraced - q_values[i]) + state_values[i]
  
              q_retraced_buffer[i] = q_retraced
  
          return q_retraced_buffer
docs: Calculate Q retraced targets