GPT Neo, Print Most Probable Next Word: String Indices Must Be Integers

This code is supposed to generate the next most probable word. However, the following problem arises.

```
!pip install git+https://github.com/huggingface/transformers.git
import torch
from transformers import GPTNeoForCausalLM, AutoTokenizer
model = GPTNeoForCausalLM.from_pretrained("EleutherAI/gpt-neo-1.3B")
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neo-1.3B")

prompt = """In the"""
prompt = prompt.strip()
text = tokenizer.encode(prompt)
myinput, past = torch.tensor([text]), None
logits, past = model(myinput, past_key_values = past)
logits = logits[0,-1]
probabilities = torch.nn.functional.softmax(logits)
best_logits, best_indices = logits.topk(10)
best_words = [tokenizer.decode([idx.item()]) for idx in best_indices]
text.append(best_indices[0].item())
best_probabilities = probabilities[best_indices].tolist()
words = []
for i in range(10):
    m = (best_words[i])
    print(m)
```

`TypeError: string indices must be integers`
You're doing something wrong here:
```py
logits, past = model(myinput, past_key_values = past)
```

The model returns a dict. Your `logits` and `past` are the keys of the dicts.

If you want the values, then either do:
```py
output = model(myinput, past_key_values = past)
logits = output.logits
past = output.past_key_values
```
or
```py
logits, past = model(myinput, past_key_values = past, return_dict=False)
```

This code must have worked with versions <=3. Please read the migration guide relative to switching to version 4 [here](https://huggingface.co/transformers/migration.html#switching-the-return-dict-argument-to-true-by-default)<|||||>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/master/CONTRIBUTING.md) are likely to be ignored.