Make torch_key_cache generic (works with any return type, not just
bytes) and add thread-safe prefetch() support. Callers can now call
func.prefetch() to start computing the cached value in a background
thread, then func() to get the result — blocking only if the background
work isn't done yet. This enables overlapping expensive cache key
computations (like torch_key and triton_key) with other startup work.
Also makes the internal state use simple optionals with nonlocal instead
of the old mutable-list-as-closure-cell pattern, and adds proper locking
for thread safety.
Authored with Claude.
Pull Request resolved: #182187
Approved by: https://github.com/aorenste, https://github.com/zou3519
SOCIAL SHARE CARD GENERATOR