Preheat the oven to 400°F.
In a large saucepan, boil the sweet potatoes in enough water to cover them for 15 minutes, or until fork-tender.
Drain well, and set aside.
While the potatoes are boiling, spiralize or slice the onion, and dip it into a small bowl containing the whisked egg.
Put the tapioca flour in one dish and the almond flour in another, and batter the onion by removing it piece by piece from the egg bowl, dipping each piece first into the tapioca flour and then into the almond flour. (If you’re short on time, you can put the onion and both flours in a large zip-top bag and shake it.)
Set aside.
In a large sauté pan over medium heat, melt the butter.
Sauté the garlic for 2 to 3 minutes before adding the sweet potatoes. Mash the potatoes (they don’t have to be perfectly smooth) with a spoon or handheld mixer, and add the coconut milk.
Season with salt and pepper.
Transfer the potatoes to an 8-by-12-inch baking dish, and top with the walnuts and onions.
Bake for 10 to 15 minutes, just until warmed through and the onions are crispy, and serve.