In a skillet add the sugar and over medium heat, without stirring too much, make a golden caramel. Add the butter and peeled onions. Also add 2 sprigs of thyme and the balsamic vinegar, salt and pepper.
Stir and add water until the onions are soft and caramelized, about 20 minutes. Reserve
Grease a mold with a removable bottom (mine is 27cm) with the rest of the butter. Cover the entire bottom of the pan and the sides with a 1/2 cm thick layer of yam. Season the rest of the yam with salt and pepper and cover the entire bottom without crushing too much. Distribute the cubed cheeses on top of this “stuffing” and push them in slightly with your fingers.
Cut the onions in half lengthwise and cover the entire pie with the halves and the caramel from the skillet, preserving the edge intact. Place some cherry tomatoes on top. Sprinkle some thyme leaves over everything.
Cover with aluminum foil and bake in an oven at 180° for 30 minutes. Uncover and bake for another 45 minutes or until golden.
Add some basil leaves and if you want a drizzle of olive oil. To unmold it more easily, let it cool down a bit. If necessary, you can heat it up a little in the oven without the rim of the mold. It should be crispy on the outside and on the bottom and soft on the inside.