Sample a constant number of tokens for masking in LM finetuning
@thomwolf @LysandreJik @julien-c Re-creating this PR as the original PR https://github.com/huggingface/transformers/pull/1555 that I created about a month ago has become quite stale. Please review.


For Masked LM fine-tuning, I think both the original BERT and RoBERTa implementations uniformly sample x number of tokens in *each* sequence for masking (where x = mlm_probability * 100 * sequence_length)
However, The current logic in run_lm_finetuning.py does an indepdendent sampling (from bernoulli distribution) for each token in the sequence. This leads to variance in the number of masked tokens (with the average number still close to x%).

The below example illustrates an extreme case, of the current logic, where no token in the input sequence is masked.

```
In [1]: import numpy as np
   ...: import torch
   ...: from transformers import BertTokenizer
   ...: 
   ...: mlm_probability = 0.15
   ...: tokenizer = BertTokenizer.from_pretrained('bert-large-uncased')
   ...: 
   ...: tokens = tokenizer.convert_ids_to_tokens(tokenizer.encode('please mask me, o lord!', add_special_tokens=True))
   ...: 
   ...: input_ids = tokenizer.convert_tokens_to_ids(tokens)
   ...: 
   ...: inputs = torch.Tensor([input_ids])
   ...: 
   ...: labels = inputs.clone()
   ...: 
   ...: probability_matrix = torch.full(labels.shape, mlm_probability)
   ...: 
   ...: special_tokens_mask = [tokenizer.get_special_tokens_mask(val, already_has_special_tokens=True) for val in labels.tolist()]
   ...: probability_matrix.masked_fill_(torch.tensor(special_tokens_mask, dtype=torch.bool), value=0.0)
   ...: masked_indices = torch.bernoulli(probability_matrix).bool()
   ...: 
   ...: 

In [2]: masked_indices
Out[2]: tensor([[False, False, False, False, False, False, False, False, False]])

```

This PR modifies the logic so the percentage of masked tokens is constant (at x).

Separately, the existing and the new masking logic both rely on boolean tensors of pytorch.
So, this also updates README to include the minimum pytorch version needed. (1.2.0)
Hi @rakeshchada, we've thought about this. It is interesting and we might merge it, but will probably will be behind a flag :)

Thanks for contributing!<|||||>This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
