I’m not familiar with the networkx library, but based on the description you would need to implement the backward functions manually, if numpy arrays are used under the hood.
Alternatively, you could also try to use PyTorch tensors instead of numpy arrays (if all operations are supported), but this sounds as if you would have to rewrite the complete library.
Could you explain a bit what networkx is doing and what your exact use case is?