Tangent space normal maps

The built-in N AOV is in world space. So how to get a tangent-space N AOV?
Like this:

In brief, I read the N AOV, transform the normals from world to tangent space, and then map the normal values to the range 0.5, 1 (I used the range node here, but I could have used Add and Multiply to do the same thing).

Here’s the shader tree. You can save this in a .ass file and import it into Maya or whatever application you use. Then set up an AOV shader to write the custom Ntangent AOV

 name aiRange1
 input space_transform
 output_min 0.5

 name space_transform
 input read_N_AOV
 type "normal"
 to "tangent"
 tangent 1 0 0
 normal 0 1 0
 normalize on

 name read_N_AOV
 aov_name "N"

 name defaultArnoldRenderOptions/aov_write_rgb_Ntangent
 aov_input aiRange1
 aov_name "Ntangent"