It's not correct. Your function (subnet) was designed to work on the code that generates the other graph (rig), not in the rig itself. One clue is that it needs a graph input.
You can design your subnet as if it were rig-code (with matrices and all the good stuff). Then you add your node to the target graph using addSubnet (to the graph). It the function was designed to work on current code (and thus, generate stuff in the target graph) you should use the function directly:
In the first picture, I'm using a custom function directly on the code (like right above). So the function is called directly - in my case:
graph, refXform = hcfx.GetRefXformHCFX(graph, targetName)
In the second image, I'm adding a custom function (subnet) into the target graph, thus, I'm using the addNode to add that to the graph.
refXformNode, exists = graph.findOrAddNode(f"{jointName}_ref_xform", "hcfx::RefXformHCFX", __name='create_ref_xform_node')
Finally, in the target graph (rig), you can see the custom function (3rd image) added as a subnet. This is the code for that node:
def RefXformHCFX(restlocal: Matrix4,
parent: Matrix4,
t: Vector3,
r: Vector3,
s: Vector3) -> Matrix4[xform]:
combinedParmXform: Matrix4 = restlocal.rig.combineParmTransform(t, r, s, mode=7, __name='combine_parm_transform')
combinedXform: Matrix4 = combinedParmXform * parent
return combinedXform
As you can see, the code above is working directly on the rig's logic; that's why it works on transforms (matrices) and so on...
(of course, that doesn't mean you shouldn't work on matrices on the code targeting the graph...)