Guard listener removal add by `at::Dispatcher::addListener()` with mutex (#35486)
Summary:
Use std::list instead of std::vector to avoid iterating over list of registered listeners
Also, fix formatting
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35486
Differential Revision: D20677764
Pulled By: malfet
fbshipit-source-id: d2a545454a29a12bbbf4aa62d9f8c4029a109e6c