add crf layer to BERT, RoBERTa, XLMR
Building on pull request [ bert（+lstm）+crf #2249 ], I make it more generic and similar to run_ner.py . There is a CRF layer adapted from https://github.com/jiesutd/LatticeLSTM , which does not have additional package requirements, and was published in ACL 2018. 
What do you think about just using https://github.com/harvardnlp/pytorch-struct (I'm biased)? It should remove the need for most of this code. 

Also we now have a pytorch-lightning NER example which should make this much simpler. 

Would also be helpful to know if any of this improves prediction accuracy.<|||||>@srush thanks for the comment, I'll definitely check out the repo. Regarding accuracy, there are studies that suggest using CRF yields better results in some languages, for example in Portugese and Slavic languages:

article{souza2019portuguese,
  title={Portuguese Named Entity Recognition using BERT-CRF},
  author={Souza, F{\'a}bio and Nogueira, Rodrigo and Lotufo, Roberto},
  journal={arXiv preprint arXiv:1909.10649},
  year={2019}
}

article{arkhipov2019tuning,
  title={Tuning Multilingual Transformers for Named Entity Recognition on Slavic Languages},
  author={Arkhipov, Mikhail and Trofimova, Maria and Kuratov, Yuri and Sorokin, Alexey},
  journal={BSNLP’2019},
  pages={89},
  year={2019}
}
<|||||>this looks promising. is this going to be merged?<|||||>So as per my above comment, I'm not going to merge this example which feels too complex to me. But I will start an issue to put together some work `crf/` examples for ner/chunking/parsing that people can build on.