run_decision_transformer 
Author: a046829713
Pull request: no

### System Info

Shouldn't we use a plus sign instead of a minus sign in run_decision_transformer.py?
![1718155431640](https://github.com/huggingface/transformers/assets/85830297/03cf9470-8f76-41e7-8d5a-a4182f27b498)


### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

for ep in range(10):
    episode_return, episode_length = 0, 0
    state = env.reset()
    state = state[0]

    target_return = torch.tensor(TARGET_RETURN, device=device, dtype=torch.float32).reshape(1, 1)
    states = torch.from_numpy(state).reshape(1, state_dim).to(device=device, dtype=torch.float32)
    actions = torch.zeros((0, act_dim), device=device, dtype=torch.float32)
    rewards = torch.zeros(0, device=device, dtype=torch.float32)

    timesteps = torch.tensor(0, device=device, dtype=torch.long).reshape(1, 1)
    for t in range(max_ep_len):
        env.render()
        # add padding
        actions = torch.cat([actions, torch.zeros((1, act_dim), device=device)], dim=0)
        rewards = torch.cat([rewards, torch.zeros(1, device=device)])

        action = get_action(
            model,
            (states.to(dtype=torch.float32) - state_mean) / state_std,
            actions.to(dtype=torch.float32),
            rewards.to(dtype=torch.float32),
            target_return.to(dtype=torch.float32),
            timesteps.to(dtype=torch.long),
        )
        actions[-1] = action
        action = action.detach().cpu().numpy()


        next_state, reward, terminated, truncated, info = env.step(action)

        cur_state = torch.from_numpy(next_state).to(device=device).reshape(1, state_dim)
        states = torch.cat([states, cur_state], dim=0)
        rewards[-1] = reward
        pred_return = target_return[0, -1] + (reward / scale)
        target_return = torch.cat([target_return, pred_return.reshape(1, 1)], dim=1)
        timesteps = torch.cat([timesteps, torch.ones((1, 1), device=device, dtype=torch.long) * (t + 1)], dim=1)

        episode_return += reward
        episode_length += 1

        if terminated:
            break

### Expected behavior

Correcting the calculation of cumulative returns, although I'm not sure if this is the right fix, it seems more appropriate given that rewards can be both positive and negative.

Comments:
@edbeeching 

Hi @a046829713 , the code line is the same as in the [original repo](https://github.com/kzl/decision-transformer/blob/e2d82e68f330c00f763507b3b01d774740bee53f/gym/decision_transformer/evaluation/evaluate_episodes.py#L125) and also the same as in the Decision transformer paper:
![Screenshot from 2024-06-12 19-11-12](https://github.com/huggingface/transformers/assets/66624139/6af1fc4d-159c-42cc-a7fa-f9fd5323d182)
![Screenshot from 2024-06-12 19-11-49](https://github.com/huggingface/transformers/assets/66624139/9c1e0aab-ac05-4558-951f-2fb4a75571e8)
As for the exact reason for the minus sign it is also mentioned in the paper just in case you missed in its reading:
![Screenshot from 2024-06-12 19-32-27](https://github.com/huggingface/transformers/assets/66624139/c8efb4fa-124c-4fa1-936b-54a2d5f3fbc1)

Cheers!


This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.