Solved by ptrblck in post #2 
              
              
                nn.Transformer was added in PyTorch 1.2.0, so you should update to the latest stable version. 
Have a look at the install instructions for the binaries: link.