nit: create a function and cache the results.
Originally posted by @houseroad in #20090 (comment)
Thanks to @houseroad, there are a lot of code like
has_pplx = importlib.util.find_spec("pplx_kernels") is not None anywhere.
Same for has_deepgemm, has_deepep etc.
We can create util function and cache the result for better readability and maintainablility.
I will have a pr for this soon.