Potential redundancy in run_classifier.py example script
https://github.com/huggingface/pytorch-pretrained-BERT/blob/7cc35c31040d8bdfcadc274c087d6a73c2036210/examples/run_classifier.py#L641-L642

Here we are calling the model twice. I understand that the model returns different things depending on the presence of `label_ids`, but this could actually be quite expensive. I think we can change the `if label is not None` branch in the model code below to return two items instead, but I'm not sure if it will break things elsewhere.

https://github.com/huggingface/pytorch-pretrained-BERT/blob/7cc35c31040d8bdfcadc274c087d6a73c2036210/pytorch_pretrained_bert/modeling.py#L969-L979

I agree with you, this part of the API could be improved.

The BERT model is now used in several third-party libraries like AllenNLP and FLAIR so we have to be careful not to make any breaking change on this model.

We could add a flag to get full output maybe.<|||||>Mind if I submit a PR adding a flag that allows getting the full output in the case of `if labels is not None`?<|||||>I'm ok to welcome a PR on that but there is one issue with flags in `forward()` call and multi-GPU you may or may not be aware of and we need to think about:
All the inputs to the `forward()` call are split across GPUs so having a non-batched input like a flag break DataParallel for multi-gpu.
So maybe we need to add a general flag in the models which can be set. Maybe you can try to draft a PR and we check it behave well on the examples then.
Maybe you can also have a deep look at the way inputs are split in DataParallel and check whether a  solution with flag in the arguments of the `forward()` call work.<|||||>Hmm, okay, I was not aware of that. I think adding it as a property on the model itself is arguably an unnecessary over-complication for a simple matter. Returning a tuple value is much cleaner and the user can always discard the information that they don't care. Although I do understand the concern of backward compatibility. So I won't do this PR and will let you guys make the decision between the two options. Personally I lean more towards the API-breaking option.<|||||>This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
