Repository: pytorch
Issue: Deprecated mask fill mask type can causes pages and pages of repeated messages
Labels: triaged

## 🐛 Bug

When I install DrQA, https://github.com/facebookresearch/DrQA , with pytorch 1.4, the mask being provided is legacy, ie torch.uint8. pytorch correctly points out that this is legacy, and should be migrated to dtype torch.bool. However, rather than printing a single warning, it prints pages and pages of warnings, presumably one for each time the masked fill is called. I feel taht the warning should only be printed once. Example partial output:

```
/tmp/pip-req-build-o37zi_pa/aten/src/ATen/native/LegacyDefinitions.cpp:19: UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.
/tmp/pip-req-build-o37zi_pa/aten/src/ATen/native/LegacyDefinitions.cpp:19: UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.
/tmp/pip-req-build-o37zi_pa/aten/src/ATen/native/LegacyDefinitions.cpp:19: UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.
/tmp/pip-req-build-o37zi_pa/aten/src/ATen/native/LegacyDefinitions.cpp:19: UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.
/tmp/pip-req-build-o37zi_pa/aten/src/ATen/native/LegacyDefinitions.cpp:19: UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.
/tmp/pip-req-build-o37zi_pa/aten/src/ATen/native/LegacyDefinitions.cpp:19: UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.
/tmp/pip-req-build-o37zi_pa/aten/src/ATen/native/LegacyDefinitions.cpp:19: UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.
/tmp/pip-req-build-o37zi_pa/aten/src/ATen/native/LegacyDefinitions.cpp:19: UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.
```

I have logged the masked fill dtype issue at https://github.com/facebookresearch/DrQA/issues/249 . However, I feel taht DrQA cannot simply upgrade this, because will likely break backwards compatibility with earlier torch versions.

I feel that the correct fix is that deprecation warnings should be printed only once per python process.

## To Reproduce

Steps to reproduce the behavior:

1. install DrQA, https://github.com/facebookresearch/DrQA (which is a facebook repo actually...)
1. run, using `python scripts/pipeline/interactive.py --tokenizer regexp`
1. type `process('what is the capital of france?')`
1. watch the spammy deprecation messages...

## Expected behavior

Print the deprecation message once, and then stop.

## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

You can get the script and run it with:
```
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```

 - PyTorch Version (e.g., 1.0): 1.4
 - OS (e.g., Linux): ubuntu 18.04
 - How you installed PyTorch (`conda`, `pip`, source): conda
 - Build command you used (if compiling from source): n/a
 - Python version: 3.6
 - CUDA/cuDNN version: 10.2
 - GPU models and configuration: cpu only
 - Any other relevant information:

## Additional context