Solved by ptrblck in post #6 
              
              
                Probably you are using an older PyTorch version, as the nn.Identity module was introduced in 1.1.0. 
Have a look here for install instructions.