[docs] missing info on call back registry
https://huggingface.co/transformers/main_classes/callback.html is missing instructions/examples on how to register a callback. Thanks.

@sgugger 
I guess the corresponding test demonstrates the usage: https://github.com/huggingface/transformers/blob/5c0bf39782c9eac8df55b89518f61c430862a7f6/tests/test_trainer_callback.py


<|||||>I don't think this issue needs to be closed, one more example could be added to the documentatio! Let's make a good first issue out of it, maybe a contributor could help there :-)<|||||>Hi @sgugger. I'm new and I'd like to start contributing. Can I work on this issue?<|||||>Sure!<|||||>Thanks. Would an example like this be okay? - 
```
class MyCallback(TrainerCallback):
    "A callback that prints a message at the beginning of training"
    
    def on_train_begin(self, args, state, control, **kwargs):
        print("Starting training")

trainer = Trainer(
    model,
    args,
    train_dataset=train_dataset,
    eval_dataset=eval_dataset,
    callbacks=[MyCallback]
)
```
Also, should I add the example to https://huggingface.co/transformers/main_classes/callback.html, or would the [training tutorial](https://huggingface.co/transformers/training.html) be a better place?<|||||>I think is should also show how to use `add_callback` as an alternative too, otherwise, that's the gist of it. The callbacks page is perfect for this I think.<|||||>Thanks, I've added an example for `add_callback` too and opened a PR [here](https://github.com/huggingface/transformers/pull/10928). It's failing some tests right now but I'm not sure why since I've only modified the `callback.rst` file. Could you please help me figure out why this might be happening?<|||||>The CI is flakey at times, I restarted the failing jobs. It looks like network problems, may have to restart again later if it still fails.

edit: no luck, still network issues, will try again later, but do not worry, as long as the docs job passes and it does - you're good.<|||||>Cool, thanks!