In case anyone runs across this particular question again, the following should work as a simple solution:
void xavier_init(torch::nn::Module& module) {
	torch::NoGradGuard noGrad;
	if (auto* linear = module.as<torch::nn::Linear>()) {
		torch::nn::init::xavier_normal_(linear->weight);
		torch::nn::init::constant_(linear->bias, 0.01);
	}
}

Then for any Linear module or module with Linear submodules, you can just initialize via module->apply(xavier_init). I think this is basically what @cheggars was suggesting with their second response.