[core] Faster and thread-safe `check_model_inputs` implementation (#43765)
* poc
* cleaner
* style
* forgot name
* fix all
* more fixes
* oupsi
* fix
* use only 1 contextvar
* lazy hook installation
* capture with lists instead of tuples
* more bad-behaved model fixes
* style
* move to dedicated file
* doc
* style