The computation graph is constructed dynamically during the forward execution, so I don’t think there is a valid workaround by e.g. just using the outputs.
Maybe a scripted model would be able to skip “unused” parts of the model, but I’m not familiar enough with the JIT.