Batch_encode_plus with is_pretokenized=True outputs incomplete input_ids
Author: ShriyaA
Pull request: no

## Environment info

- `transformers` version: 2.11.0
- Platform: Linux-4.19.112+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- PyTorch version (GPU?): 1.5.1+cu101 (True)
- Tensorflow version (GPU?): 2.3.0 (True)
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No

### Who can help

 tokenizers: @mfuntowicz

## Information

Model I am using (Bert, XLNet ...): Distilbert, Roberta

I am trying to use batch_encode_plus with pretokenized inputs but the input_encodings are different than if the same text is run individually through encode_plus or if the same text is batch encoded without pretokenization.

## To reproduce

Code and outputs:

```python
tokenizer = AutoTokenizer.from_pretrained('distilbert-base-cased', use_fast=True)
input_text = ['Roman Atwood is a content creator.', 'The Boston Celtics play their home games at TD Garden.']
sample_batch = [x.split(' ') for x in input_text]
sample_batch
```
Output: [['Roman', 'Atwood', 'is', 'a', 'content', 'creator.'],
 ['The', 'Boston',  'Celtics', 'play', 'their', 'home', 'games',  'at', 'TD', 'Garden.']]

```python
encoded_dict_batch = tokenizer.batch_encode_plus(sample_batch, is_pretokenized=True, padding=True, return_tensors='pt', truncation=True, max_length=125)
print(encoded_dict_batch)
```

The output is this which was far fewer non-zero tokens than I expected:

{'input_ids': tensor([[ 101, 2264,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,  102],
        [ 101, 1109,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
            0,    0,    0,    0,  102]]), 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1],
        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
         1, 1, 1, 1, 1]])}

The attention mask is also a problem with all the padded indices being 1s.

Run only the first sentence through encoding (not in batch). All other parameters remain the same.

```python
encoded_dict_single = tokenizer.encode_plus(sample_batch[0], is_pretokenized=True, padding=True, return_tensors='pt', truncation=True, max_length=125)
print(encoded_dict_single)
```
This produces a much more sane output:

{'input_ids': tensor([[ 101, 2264, 1335, 2615, 1110,  170, 3438, 9264,  119,  102]]), 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])}

The input ids here from index 2 onwards are replaced by 0 in the previous output even though it's well below max_length.

The words are truncated as well:

```python
print(encoded_dict_single.words())
print(encoded_dict_batch.words())
```
[None, 0, 1, 1, 2, 3, 4, 5, 6, None]
[None, 0, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]

Strangely enough, when calling batch_encode_plus with a pretokenized batch that consists of only 1 item in the list, it works fine.

```python
batch_of_one = [sample_batch[0]]
encoded_dict_batch_of_one = tokenizer.batch_encode_plus(batch_of_one, is_pretokenized=True, padding=True, return_tensors='pt', truncation=True, max_length=125)
print(encoded_dict_batch_of_one)
```
Output:
{'input_ids': tensor([[ 101, 2264, 1335, 2615, 1110,  170, 3438, 9264,  119,  102]]), 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])}

I've tried with roberta as well and had the same results. Also, the same sentences in a batch but without pretokenization produces the correct outputs. It seems to be only the combination of pretokenized and batched sentences that are a problem.

## Expected behavior

The input_ids should not be replaced by 0s when tokenizing batched and pre-tokenized inputs.


Comments:
I ran this example using the v3.1.0 and it seems the issue was resolved in the latest versions:

```py
from transformers import AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained('distilbert-base-cased', use_fast=True)
input_text = ['Roman Atwood is a content creator.', 'The Boston Celtics play their home games at TD Garden.']
sample_batch = [x.split(' ') for x in input_text]
print(sample_batch)

encoded_dict_batch = tokenizer.batch_encode_plus(sample_batch, is_pretokenized=True, padding=True, return_tensors='pt', truncation=True, max_length=125)
print(encoded_dict_batch)
```
outputs

```
[['Roman', 'Atwood', 'is', 'a', 'content', 'creator.'], ['The', 'Boston', 'Celtics', 'play', 'their', 'home', 'games', 'at', 'TD', 'Garden.']]
{'input_ids': tensor([[  101,  2264,  1335,  2615,  1110,   170,  3438,  9264,   119,   102,
             0,     0,     0],
        [  101,  1109,  2859, 25931,  1505,  1147,  1313,  1638,  1120, 15439,
          5217,   119,   102]]), 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0],
        [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])}
```

Would it be possible for you to upgrade to version v3.1.0?

I was able to upgrade to 3.0.2 and it was working with that. Thanks!