Set a skillet over medium heat. When hot, toast the chile pieces a few at a time, pressing them to the hot surface with a spatula until they are aromatic and lightened in color underneath—about 10 seconds per side. (If you see more than a whiff of smoke, they are burning.) Transfer toasted chiles to medium sized saucepan and pour in the milk. Over medium heat, bring the milk to a simmer, cover and let steep for 20 minutes. For a mild chile flavor, discard the ancho. For a more robust flavor, place 1/4 of the ancho in a blender along with the milk and puree smooth. Stir in the espresso powder and let the milk cool to room temperature before proceeding with the recipe.
In a medium bowl, whisk the eggs thoroughly. Set aside.
In a medium heavy saucepan, mix the sugar, cocoa, cornstarch, and salt. Pour in about 1/2 cup milk and whisk to make a smooth paste, then whisk in the rest of the milk. Heat the mixture over medium heat, stirring with a spatula, until the mixture begins to bubble around the edges. Adjust the heat to maintain a steady low boil and stir constantly for 2 minutes or until the mixture has thickened, taking care to scrape the bottom and sides of the pan constantly to avoid scorching. Remove from the heat.
Slowly ladle about 1 cup of the hot mixture gradually over the eggs, whisking constantly to prevent the eggs from scrambling. Scrape the egg mixture back into the pan and whisk vigorously to bring the mixture together. Set the pan over medium-low heat and whisk for 30 seconds, without the mixture coming to a simmer, to be sure that the eggs are hot enough. Remove from the heat and add the vanilla and both chocolates and whisk until the mixture is smooth.
Transfer the pudding to a clean bowl and place a piece of plastic wrap directly on the surface to prevent a skin from forming as the pudding cools. Place in the refrigerator to cool completely.
Once the mixture has cooled completely, spoon the pudding into the pastry shells and top with a dollop of whipped cream and a sprinkle of shaved chocolate.
COOK'S NOTE: You can anchor the bowl to the countertop for easier whisking by placing the bowl on top of the rubberized mat material that they sell to line shelves or refrigerator produce bins. These same matsalso work well for anchoring cutting boards, and they're dishwasher safe.