[ONNX] Align Optional Type in block (#83599)
Why:
Previously, we use `replaceAlluseswith` after adding Optional on the node which is right before output. However, this may break the graph by also changing the nodes that needs the node (original) as input. We only need the node to be optional in output.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/83599
Approved by: https://github.com/justinchuby, https://github.com/BowenBao, https://github.com/malfet