 module 'torch.nn' has no attribute 'Identity'
Traceback (most recent call last):
  File "trainer.py", line 17, in <module>
    model = XLMForSequenceClassification(config)
  File "/home/ankit/anaconda3/lib/python3.6/site-packages/pytorch_transformers/modeling_xlm.py", line 823, in __init__
    self.sequence_summary = SequenceSummary(config)
  File "/home/ankit/anaconda3/lib/python3.6/site-packages/pytorch_transformers/modeling_utils.py", line 734, in __init__
    self.summary = nn.Identity()
AttributeError: module 'torch.nn' has no attribute 'Identity'



https://github.com/huggingface/pytorch-transformers/blob/2f869dc6651f9cf9253f4c5a43279027a0eccfc5/pytorch_transformers/modeling_utils.py#L734
This was added in PyTorch 1.1.0 (see [changelog here](https://github.com/pytorch/pytorch/tree/v1.1.0) :)

So I guess you just have to update your PyTorch version!<|||||>Oh yes, I guess we can add a replacement to keep older PyTorch compatibility.
Would be sad to lose backward compatibility just for this.<|||||>Is this replacement added in any of the newer versions?