Getting one transform relative to another

Godot Version

3.x

Question

Hello there,
So I’m currently compiling Godot 3 with some changes to achieve a good active ragdoll. Thing is, I want to apply inverse kinematics on godot 3 “custom pose”, but in the poses hierarchy is rest_pose->custom_pose->bone_pose, and thus, I’m having a hard time on getting things right. I already made it apply on the pose (the same in wich the animations are applied) sucessfuly, but since godot 3 still have this “custom pose” (wich are not used normally), I wanted to use it exclusively for the inverse kinematics. The reason behind this, is that the physical bones simulation already use the global pose override, and thus, would not work together with the IK. I readed the docs, but still couldn’t make it work. So by now i have my IK pose already converted to local pose, and in my last try I made it like this:
custom_pose * bone_pose
because I thought it would return the difference between the custom pose defined by IK and the animation pose, running in the bone_pose, but the results were messy. If I just override the animation bone_pose (applied on top of custom_pose, normally a clear transform) with my converted IK pose, it works good.
So the question is, how do I get the transform necessary to fit the custom_pose? That way both animation and ik would be running the same time.