Add device_of overload for optional<Tensor> (#54262)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54262
register_dispatch_key.py might generate device_of call over
optional<Tensor> if it happened to be the first Tensor-like
argument.
ghstack-source-id: 124535550
Test Plan: Test together with next diff in stack
Reviewed By: ezyang
Differential Revision: D27164093
fbshipit-source-id: 3b0400d5d603338e884218498106f6481e53f194