Modify DispatchKeyExtractor to also work for optional Tensors (#58283)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/58283
Reviewed By: bhosmer
Differential Revision: D28436443
Pulled By: Chillee
fbshipit-source-id: ba6aae74e8ec3c5a6157cc4517c29b36bdd4a30d