

TITLE
run_pl_glue.py token_type_id error on fresh install

COMMENTS
4

REACTIONS
+1: 0
-1: 0
laugh: 0
hooray: 0
heart: 0
rocket: 0
eyes: 0

BODY
If you try to run the run_glue.py example with e.g. roberta from a fresh install of the library, it errors out with the following error:

```
Traceback (most recent call last):
  File "examples/text-classification/run_pl_glue.py", line 228, in <module>
    main()
  File "examples/text-classification/run_pl_glue.py", line 218, in main
    trainer = generic_train(model, args)
  File "/home/ejp416/complexity/examples/lightning_base.py", line 400, in generic_train
    trainer.fit(model)
  File "/home/ejp416/miniconda3/envs/complexity2/lib/python3.7/site-packages/pytorch_lightning/trainer/states.py", line 48, in wrapped_fn
    result = fn(self, *args, **kwargs)
  File "/home/ejp416/miniconda3/envs/complexity2/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1072, in fit
    model = self.accelerator_backend.setup(model)
  File "/home/ejp416/miniconda3/envs/complexity2/lib/python3.7/site-packages/pytorch_lightning/accelerators/gpu_backend.py", line 34, in setup
    self.trainer.call_setup_hook(model)
  File "/home/ejp416/miniconda3/envs/complexity2/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 1444, in call_setup_hook
    model.setup(stage_name)
  File "/home/ejp416/complexity/examples/lightning_base.py", line 175, in setup
    self.train_loader = self.get_dataloader("train", self.hparams.train_batch_size, shuffle=True)
  File "examples/text-classification/run_pl_glue.py", line 98, in get_dataloader
    all_token_type_ids = torch.tensor([f.token_type_ids for f in features], dtype=torch.long)
TypeError: an integer is required (got type NoneType)
```

To reproduce, run e.g.

```
python examples/text-classification/run_pl_glue.py --model_name_or_path roberta-base --output_dir ./blah --task mnli --do_train --data_dir ./glue_data/MNLI --max_seq_length 512 --max_grad_norm inf --adam_epsilon 1e-6 --weight_decay 0.1 --num_train_epochs 2 --train_batch_size 2 --eval_batch_size 4 --learning_rate 1e-5 --seed 12 --gradient_accumulation_steps 8 --gpus 1
```

The reason is that roberta does not have segment ids so token_type_ids is set to null in the data loader, causing torch.tensor to freak out. There's probably a more elegant long-term solution for this, but it's easy to fix by just setting it to 0 instead of null for those models. This issue has come up before in other scripts:
- https://github.com/huggingface/transformers/pull/3801
- https://github.com/huggingface/transformers/issues/3810