ValueError: DataLoader with IterableDataset: expected unspecified sampler option,
Author: Pradhy729
Pull request: no

# 🐛 Bug

## Information

This is in regards to the `Trainer` object. The `get_train_dataloader` function uses RandomSampler or Distributed sampler, both of which I believe won't work with an [iterable datasets](https://pytorch.org/docs/stable/data.html#iterable-style-datasets) - which are only compatible with InfiniteConstantSampler see [pytorch documentation](https://pytorch.org/docs/stable/_modules/torch/utils/data/dataloader.html#DataLoader)

https://github.com/huggingface/transformers/blob/d088d744adb4e5aa45262a34acab3ae9e81de169/src/transformers/trainer.py#L229-L242

## Steps to reproduce the behavior:
1. Create an Iterable dataset and pass it to trainer object.

Gives the following error:
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<timed eval> in <module>

~/.conda/envs/my_root/lib/python3.6/site-packages/transformers/trainer.py in train(self, model_path)
    382                 training will resume from the optimizer/scheduler states loaded here.
    383         """
--> 384         train_dataloader = self.get_train_dataloader()
    385         if self.args.max_steps > 0:
    386             t_total = self.args.max_steps

~/.conda/envs/my_root/lib/python3.6/site-packages/transformers/trainer.py in get_train_dataloader(self)
    247             sampler=train_sampler,
    248             collate_fn=self.data_collator,
--> 249             drop_last=self.args.dataloader_drop_last,
    250         )
    251 

~/.conda/envs/my_root/lib/python3.6/site-packages/torch/utils/data/dataloader.py in __init__(self, dataset, batch_size, shuffle, sampler, batch_sampler, num_workers, collate_fn, pin_memory, drop_last, timeout, worker_init_fn, multiprocessing_context)
    177                 raise ValueError(
    178                     "DataLoader with IterableDataset: expected unspecified "
--> 179                     "sampler option, but got sampler={}".format(sampler))
    180             elif batch_sampler is not None:
    181                 # See NOTE [ Custom Samplers and IterableDataset ]

ValueError: DataLoader with IterableDataset: expected unspecified sampler option, but got sampler=<torch.utils.data.sampler.RandomSampler object at 0x7fff5803b2b0>

## Expected behavior

Ideally, we should check if the dataset is an iterable dataset and if so, pass no sampler to the dataloader. Or allow the option of passing in our own sampler to the trainer.

## Environment info

- `transformers` version: 3.0.2
- Platform: Linux-4.4.121-92.104-default-x86_64-with-SuSE-12-x86_64
- Python version: 3.6.10
- PyTorch version (GPU?): 1.5.1 (False)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: NO
- Using distributed or parallel set-up in script?: NO

I can contribute and create a PR to fix this. Let me know.

Comments:
Thanks for the fix with #5834 :)

The same issue exists for _get_eval_sampler... I patched the Trainer in the mean time, but it would be good if it were fixed.

Hi @avercau can you open an issue with your problem? Thank you