Lightly grease a 5-by-9 inch loaf pan using a little of the margarine.
Place the remaining margarine, sugar, cocoa, vanilla and soy milk in a heatproof mixing bowl or the upper part of a double boiler. Place the bowl or boiler over simmering water and stir until smooth. Add the walnuts, if desired.
Pour the mixture quickly into the prepared pan. Chill thoroughly and cut into squares.
Recipe by Go Dairy Free at https://www.godairyfree.org/?p=162023