get output from a particular layer of pre-trained transformer (xlnet) 
As the title, how can I do this in PyTorch version of pre-trained transformer?   
Sure, these are called hidden states! Here's the [documentation of the XLNet model](https://huggingface.co/transformers/model_doc/xlnet.html?highlight=output_hidden_states#transformers.XLNetModel).

Please note the third return:

> **hidden_states (tuple(torch.FloatTensor), optional, returned when config.output_hidden_states=True):**
> 
> Tuple of torch.FloatTensor (one for the output of the embeddings + one for the output of each layer) of shape (batch_size, sequence_length, hidden_size).
> 
> Hidden-states of the model at the output of each layer plus the initial embedding outputs.
