Wrap the tofu in paper towels and, applying some pressure, remove as much liquid as possible. Then cut the tofu into cubes.
Mix garlic, lime juice, and soy sauce. Add the tofu and let it marinate for at least 30 minutes.
In a small saucepan, roast the cashews and season with salt. Remove from the pan, let cool, and roughly chop.
For the sambal sauce, finely chop the shallots, garlic cloves, chilies, makrut lime leaves, and coriander stems.
Heat the oil in a pan over medium heat. Add the shallots, garlic, chilies, makrut lime leaves, coriander stems, and star anise, and cook for 20 minutes, stirring occasionally.
Meanwhile, prepare the pickled ginger. To do this, heat the vinegar, sugar, and salt in a small saucepan. Once the liquid starts to simmer, remove from the heat and add the ginger. Let cool.
After 20 minutes, when the sambal ingredients are golden brown, add the chili flakes, caraway seeds, turmeric, tomato paste, maple syrup, and 1 teaspoon of salt. Roast for another 5 minutes. Then add the water and keep warm.
Heat oil in a pan. Remove the tofu from the marinade and fry on all sides. After frying, toss the tofu once more in the marinade, then add it to the sambal sauce.
Add the coriander leaves to the pickled ginger.
Arrange the tofu on a plate and scatter the cashews and pickled ginger over the top.