[ONNX] Fix bug using std::copy_if (#80999)
`std::copy_if` requires pre-allocated destination. Hence `scopes` needs to either be pre allocated, or use `std::inserter` for copy. Ref: https://en.cppreference.com/w/cpp/algorithm/copy
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80999
Approved by: https://github.com/AllenTiTaiWang, https://github.com/garymm