For the soup, place the tofu blocks on a plate, place another plate on top, and weight with a jar or 14 to 28-ounce can. Let stand for 30 minutes. Water will be pressed out of the tofu as it stands; drain it off every 15 minutes or so. Cut the tofu into 1/2-inch cubes and set aside.
Use your fingers to squeeze and press the tamarind to dissolve it completely and to squeeze the last of the pulp off any seeds and pith. Place a sieve over a small bowl and pour the tamarind water through. Discard any solids and set the liquid aside.
If the okra is large, cut crosswise in 1/2 and cut off any tough tips, leaving the stems on.
For the garnish, heat the oil in a small heavy skillet over medium-high heat. Add the shallots and cook until well-browned, then remove from the heat and set aside.
To make the soup, place the tamarind liquid and the 5 cups water in a large nonreactive pot. Bring to a vigorous boil, then add the okra (if your okra is very fresh and tender, add it later, with the tomato wedges) and pineapple. Boil vigorously for 3 minutes, then add the bac ha, if using, the sugar, salt, and tomato wedges. Bring back to a boil, then add the tofu cubes and soy sauce and cook for 2 minutes. Taste and adjust the balance of seasonings if you wish.