All the Function have a .metadata field that is a dictionnary that you can use to save anything you want associated with it.
The problem is that the Functions that you encounter in the computational graph are the ones implementing the backward. These are created during the forward pass of the forward ones and given  everything they need.
The thing is that these forward Functions are mostly created automatically based on this derivatives.yaml 8 file. The other ones are created by the files in this 5 folder. And the python created Functions are handled by the python_function.cpp 5 file and some python class magic from FunctionMeta 6.
You would need to modify the metadata field of the newly created backward function in each of these 3 places. The last one should be fairly easy, the second one is going to be annoying as you will need to change the code of every single Function declared in that folder and for the first one, you will need to dive into the automaticly generated code and handle all the weird cases for all Function (the ones that do inplace op and don’t have output, or ones that have outputs called out or self…).