rewrite hole macro to return lists of relevant gates instead of functions and add helper functions and finish writing training test function