title: Cross Entropy Loss, IndexError: Target -1 is out of bounds
body: <p>When I try to train a pre-trained model from Hugging Face <strong>DistilBertForTokenClassification</strong> , I get an error after running.</p>
  <p>This is the code:</p>
  <pre><code>from transformers import DistilBertForTokenClassification
  model = DistilBertForTokenClassification.from_pretrained('distilbert-base-cased',num_labels=len(unique_tags))
  
  from transformers import Trainer, TrainingArguments
  
  training_args = TrainingArguments(
      output_dir='./results',          # output directory
      num_train_epochs=3,              # total number of training epochs
      per_device_train_batch_size=16,  # batch size per device during training
      per_device_eval_batch_size=64,   # batch size for evaluation
      warmup_steps=500,                # number of warmup steps for learning rate scheduler
      weight_decay=0.01,               # strength of weight decay
      logging_dir='./logs',            # directory for storing logs
      logging_steps=2,
  )
  
  trainer = Trainer(
      model=model,                         # the instantiated  Transformers model to be trained
      args=training_args,                  # training arguments, defined above
      train_dataset=train_dataset,         # training dataset
      eval_dataset=val_dataset             # evaluation dataset
  )
  
  trainer.train()
  </code></pre>
  <p>This is the error:</p>
  <pre><code>IndexError                                Traceback (most recent call last)
  &lt;ipython-input-25-048e8cb92b09&gt; in &lt;module&gt;()
       23 )
       24 
  ---&gt; 25 trainer.train()
  
  7 frames
  /usr/local/lib/python3.7/dist-packages/torch/nn/functional.py in cross_entropy(input, target, weight, size_average, ignore_index, reduce, reduction)
     2822     if size_average is not None or reduce is not None:
     2823         reduction = _Reduction.legacy_get_string(size_average, reduce)
  -&gt; 2824     return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
     2825 
     2826 
  
  IndexError: Target -1 is out of bounds.   
  </code></pre>
  <p>Can someone please help?</p>