AG normal map to RGB normal map
This tree reproduces the function you describe:



It could be made smaller, but I hope this is more self-explanatory. Note that this is Non-Color data, set in the input image.