Baking Metallic map? Hey what's the best way to bake Metallic maps since it's not one of the types of baking blender's interface offers you?

I know about plugin your metalic node setup into a diffuse node and bake that, but it can get tricky if you use multiple Mix Shader nodes making your material (so your metallic information could be split among tons of tons all over the place).

I need to do it through code reliably, if possible.
Metallic maps are maps that tell the shader which parts of the object to make metal, and which to make dieletric.  If you want to make a custom map, the best way to do it in my opinion would be to texture paint a black and white map in blender.  it's not really a type of map you can bake.

hope this is helpful :)