Cache guards once per variable tracker, rather than re-propagating them repeatedly (#89827)
This improves tracing performance of optimizer tracing significantly (2x). In essence this just removes the recursion from propagate because it is not necessary. ListVariables and ConstDictVariables already contain the guards from the items contained in them.
Adds two other optimizations for special cases of `recursively_contains`
helps with https://github.com/pytorch/torchdynamo/issues/1803
Pull Request resolved: https://github.com/pytorch/pytorch/pull/89827
Approved by: https://github.com/anijain2305, https://github.com/jansel