Add early stopping to trainer_tf.py
## Summary
This PR adds the early stopping feature to trainer_tf.py.

## Related Issues
Alongside #4186 should close #4894.

## Who can review?

@sgugger & @BramVanroy.

Thanks @KMFODA!

I'm not really in favor to do this manually as there are already a Keras callbacks taking care of this https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/EarlyStopping that can monitor multiple values on which to base his early stop.

@KMFODA if you want to add the feature to add Keras callbacks handling, it will be more than welcome :) As it is part of the features we plan to add in a near future.<|||||>Seeing that I have close to no experience with TF, I won't be able to review this.<|||||>Not a problem. @jplu I agree I prefer using Keras callbacks I just only have experience using it with Keras’s model.fit function. I’ll think and experiment with how to use it in a custom built TF model. Hopefully if successful, it should be fairly simple then to add early stopping based on custom metrics rather than just validation loss.<|||||>I've just pushed the latest changes to trainer_tf.py that will use Keras's callbacks for early stopping rather than the manual solution I had initially submitted. Setting the callback in the `TFTrainer` function using a command such as this:

`callbacks = [EarlyStopping(monitor='loss', patience=1, verbose=1)]
`

will monitor the training loss and stop the model at the first epoch which fails to improve on the best training loss metric. Using the monitor variable we can also select metrics, other than the training loss, to carry out the early stopping on.<|||||>Hi all, anything more I can do to help get this merged?<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.<|||||>Bump @LysandreJik @jplu <|||||>We're moving away from the TFTrainer to fully integrate with Keras, so we won't add new functionality to the TFTrainer.<|||||>> We're moving away from the TFTrainer to fully integrate with Keras, so we won't add new functionality to the TFTrainer.

Alright, sounds good, This can be closed then?<|||||>I'll let the original author close it :-)