added save_as_code to tensor_stack