XLNetLMHeadModel: target mapping with num_predict > 1 and labels not working
Hi,

While trying to fine tune the XLNetLMHeadModel, I ran into the following error message:

`  File "[...]/lib/python3.8/site-packages/torch/nn/modules/module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)
  File "[...]/lib/python3.8/site-packages/transformers/modeling_xlnet.py", line 1062, in forward
    loss = loss_fct(logits.view(-1, logits.size(-1)), labels.view(-1))
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
`

while calling the forward function like this:


               outputs = xlnet(input, # shape = (8, 50)

                                 attention_mask=attention_mask, # shape = (8, 50)

                                 perm_mask=perm_mask, # shape = (8, 50, 50)

                                 target_mapping=target_mapping, # shape = (8, 2, 50)

                                 token_type_ids=sequence_ids, # shape = (8, 50)

                                 labels=target) # shape = (8, 2)


According to the [docs](https://huggingface.co/transformers/model_doc/xlnet.html#transformers.XLNetLMHeadModel) the labels shape is expected to be (batch_size, num_predict). However using this shape causes the above mentioned error.

The error does not appear if we set num_predict to 1 and set labels.shape = torch.size([8])
The error also does not appear if we omit the labels and manually compute the loss 
Hi @hannodje,

sorry to answer so late. Could you provide a complete code sample that can reproduce the error? One in which you set define all the variables `input`, `attention_mask`, `perm_mask`, `target_mapping`, `sequence_ids` and `target` and which defines which XLNetLMHeadModel you use. Ideally, I can copy / paste the code sample in a script without having to add code of my own to reproduce the error :-)  It's kinda hard to reproduce the error otherwise. Thanks!