[SR] Apply all graph passes to sub-blocks (#72598)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/72598
Apply all optimizations to sub-blocks by replacing loops over `graph->nodes()` with loops over nodes in `DepthFirstGraphNodeIterator`
ghstack-source-id: 149155700
Test Plan: Existing unit tests
Reviewed By: d1jang
Differential Revision: D34111430
fbshipit-source-id: 015076030368bb67df24ed5892475534b8f8f272
(cherry picked from commit a4314520de2f3d56326434feea63c39c6d1f7cc4)