def compute_returns(self, next_value, use_gae, gamma, tau):
    if use_gae:
        self.value_preds[(- 1)] = next_value
        gae = 0
        for step in reversed(range(self.rewards.size(0))):
            delta = ((self.rewards[step] + ((gamma * self.value_preds[(step + 1)]) * self.masks[(step + 1)])) - self.value_preds[step])
            gae = (delta + (((gamma * tau) * self.masks[(step + 1)]) * gae))
            self.returns[step] = (gae + self.value_preds[step])
    else:
        self.returns[(- 1)] = next_value
        for step in reversed(range(self.rewards.size(0))):
            self.returns[step] = (((self.returns[(step + 1)] * gamma) * self.masks[(step + 1)]) + self.rewards[step])
def compute_returns(self, next_value, use_gae, gamma, tau):
    if use_gae:
        self.value_preds[(- 1)] = next_value
        gae = 0
        for step in reversed(range(self.rewards.size(0))):
            delta = ((self.rewards[step] + ((gamma * self.value_preds[(step + 1)]) * self.masks[(step + 1)])) - self.value_preds[step])
            gae = (delta + (((gamma * tau) * self.masks[(step + 1)]) * gae))
            self.returns[step] = (gae + self.value_preds[step])
    else:
        self.returns[(- 1)] = next_value
        for step in reversed(range(self.rewards.size(0))):
            self.returns[step] = (((self.returns[(step + 1)] * gamma) * self.masks[(step + 1)]) + self.rewards[step])