FX function refactor
# What does this PR do?

This PR just refactors some pieces of code that are useful in `symbolic_trace` so that they can be used as standalone functions, and in other libraries, for instance [here](https://github.com/huggingface/optimum/pull/216/files#diff-7b6db6e19d4646fd3712298b1abef6ab3ba778d9a9c411aed1d12599ec25725fR164). 
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_17625). All of your documentation changes will be reflected on that endpoint.