QA Documentation: I got error just copy and pasting documentation
## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.3.1
- Platform:Manjaro Linux
- Python version: 1.5.1
- PyTorch version (GPU?): Yes
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No

### Who can help
@sgugger 

## Information
I am trying the to train a QA model following the huggingface documentation, I just copied and pasted the code in my machine (and in Colab) but I was not able to proceed in the training phase because I got None value.
## To reproduce

Steps to reproduce the behavior:

1. Go to the documentation: https://huggingface.co/transformers/custom_datasets.html at Squad training section
2. Copy and paste the code as you can see from my pastebin: https://pastebin.com/hZvq7Zs7
3. And you got the following error
`File "/home/andrea/PycharmProjects/qa-srl/test.py", line 78, in __getitem__
    return {key: torch.tensor(val[idx]) for key, val in self.encodings.items()}
RuntimeError: Could not infer dtype of NoneType
`
4. My naive solution was modifying the __getitem__ method from the SquadDataset class in order to avoid to serve the val[idx] == None

Pinging @joeddav on this one, since he wrote this tutorial :-)<|||||>Thank you @sgugger for the reply.
Ok I can wait for the answer from @joeddav.

Have a nice day. <|||||>Figured it out. `answer_end` is the character position immediately _after_ the answer, so end_position should be derived from `answer_end - 1`. I'm not sure why I was able to run it without this error previously (perhaps a resolved tokenizer bug?), but this should be correct.

```python
def add_token_positions(encodings, answers):
    start_positions = []
    end_positions = []
    for i in range(len(answers)):
        start_positions.append(encodings.char_to_token(i, answers[i]['answer_start']))
        end_positions.append(encodings.char_to_token(i, answers[i]['answer_end'] - 1))
 
        # if start position is None, the answer passage has been truncated
        if start_positions[-1] is None:
            start_positions[-1] = tokenizer.model_max_length
            end_positions[-1] = tokenizer.model_max_length

    encodings.update({'start_positions': start_positions, 'end_positions': end_positions})
```<|||||>Closed by #10217 <|||||>Thank you @joeddav the posted code works perfectly. 
<|||||>Sorry for bothering you @joeddav again, I have a question related to the code posted by you here. 
I am still getting None with the dataset built by myself using this code. My dataset works perfectly with the run_squad original script.
In this snipped posted by you I encounter None in the vector of end_positions and I don't know how fix it. I saw the condition in which there's a None the start_positions but what I have to do in the case the None is only in the end_positions vector?

Kind regards,
Andrea