Embedding index out of range in self
Author: zht1130
Pull request: no

# 🐛 Bug

## Information

Model I am using (Bert, XLNet ...): Bert cased (size=768)

Language I am using the model on (English, Chinese ...): English

The problem arises when using:
* [ ] the official example scripts: (give details below) 
* [ ] my own modified scripts: (give details below) When I feed the ids converted by BERTtokenizer to BERT embedding layer, it shows that the dimension does not match.

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [ ] my own task or dataset: (give details below) task: text binary classification. dataset: ICLR2020 peer reviews

## To reproduce

Steps to reproduce the behavior:

1. use BERT model and BERT tokenizer
2. convert the text of any datasets to ids
3. feed to the BERT model

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior

The dimension should match. Actually, the code works two days ago. I did not change anything and today it does not work.

The error is: return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) and index out of range in self.

## Environment info

2020-06-23 23:18:22.738569: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/transformers/commands/env.py:36: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2020-06-23 23:18:24.794569: I tensorflow/core/platform/cpu_feature_guard.cc:143] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX512F
2020-06-23 23:18:24.849719: I tensorflow/core/platform/profile_utils/cpu_utils.cc:102] CPU Frequency: 2000160000 Hz
2020-06-23 23:18:24.850210: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x42a8bc0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-06-23 23:18:24.850259: I tensorflow/compiler/xla/service/service.cc:176]   StreamExecutor device (0): Host, Default Version
2020-06-23 23:18:24.857345: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1
2020-06-23 23:18:24.860619: E tensorflow/stream_executor/cuda/cuda_driver.cc:313] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2020-06-23 23:18:24.860659: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (68cbbf79e491): /proc/driver/nvidia/version does not exist

Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

- `transformers` version: 2.11.0
- Platform: Linux-4.19.104+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- PyTorch version (GPU?): 1.5.1+cu101 (False)
- Tensorflow version (GPU?): 2.2.0 (False)
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
    


Comments:
Hi,
Can you share a self-contained code example reproducing the bug?

> Hi,
> Can you share a self-contained code example reproducing the bug?

Sorry, I think it is due to a bug in my code. Please close it.

@zht1130 Were you able to identify the bug? I'm seeing a similar error.

> @zht1130 Were you able to identify the bug? I'm seeing a similar error.

1. Run the model on the CPU instead of GPU will give you more detailed information.
2. BERT layer only receives token ids whose length smaller than 512.