Propagate callable parameter types using ParamSpec (#142306) (#143797)
Summary:
The codebase has a few locations where callable parameter type information is lost when the unpackings *args and **kwargs are typed as Any. Refactor these instances to retain type information using typing_extensions.ParamSpec.
Also, in these functions, enforce return type with TypeVar.
Addresses #142306
X-link: https://github.com/pytorch/pytorch/pull/143797
Approved by: https://github.com/Skylion007
Reviewed By: jeanschmidt
Differential Revision: D67707277
fbshipit-source-id: 18e8dbde435a46e9dca17e3c81d1dd019601cf1d
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
Co-authored-by: Xuehai Pan <XuehaiPan@outlook.com>