Ref: https://github.com/microsoft/onnxscript/pull/2518/files#r2305733402
Currently the rewrite rules use instance properties for storing intermediate results. This can be bad because the states are not freed after the rule is done, and risk contaminating future rewrites (side effects). We should create a managed cache that is cleared every time a rewrite is done.