I am also curious and I still have not figured out how to do that.
Right now I am looking at test code here: pytorch/test_fx.py at ebf7a4f843ac2c34f0f0765c57f8c0bb8a194686 · pytorch/pytorch · GitHub 2
There is some functionality to add and delete some atomic functions, however, I am not sure if it is possible to replace bigger classes.