Preheat the oven to 325°F. In a pot, bring the sugar and water to a boil and wait until the sugar turns golden brown and the caramel starts to thicken up a little bit. Now pour the caramel into the loaf pan and let it cool.
For the custard layer, add the egg yolks, eggs, sweetened condensed milk, heavy cream, vanilla extract, and milk to a bowl and whisk well until combined. Pour the mixture over the caramel in the loaf pan.
For the chocolate base, separate the egg yolks from the egg whites. Add the flour, cocoa powder, milk, baking powder, vegetable oil, baking soda, vanilla extract, and salt to the egg yolks and mix with a hand mixer. Add the sugar to the egg whites, whisk until stiff peaks start to form, and then gently fold the meringue into the chocolate egg yolk mixture.
Pour the chocolate base over the custard layer in the loaf pan. Fill a deep baking tray with water, place the loaf pan in the middle, transfer the baking tray to the oven, and bake for 90 minutes. Refrigerate the flan overnight and then flip it over on a nice serving platter the next day.