This is purposefully not exposed, the only way to get a graph is by compiling code with torch.jit.script or tracing with torch.jit.trace. Potentially you could extract the code you are compiling initially with the Python inspect module and edit it that way, so it would be changed in the way you want before TorchScript sees it.
You could also drop down to C++ (and potentially use PyBind to make it callable from Python) and write a custom pass that operates on a Graph object, see this tutorial 15 for details.