A dynamic brake is a device for retardation that can be fitted to any vehicle with an electrical transmission. It is most commonly fitted to railway locomotives, but could also be fitted to such things as heavy construction and mining machinery which can also have diesel-electric power. I am most familiar with the locomotive application, however.
Dynamic brakes have been fitted both to diesel-electric and other self powered locomotives with electric transmission (such as gasoline-electric and turbine-electric locomotives), and also to some straight electric locomotives -- those obtaining electrical power from an external source.
Dynamic braking takes advantage of the fact that an electric motor is pretty much the same thing as a generator. In other words, as well as converting electrical energy into mechanical energy to power a train, they can convert excess mechanical energy into electrical energy to slow the train down.
In order for this to work, the traction motors, now generators, need a load to work against. To a limited degree, of course, they can power the locomotive's and train's systems, but they don't require a huge amount of power. What to do with the rest?
The normal answer is to throw it away, just as is done with conventional brakes -- and in the same way, by converting it to thermal energy -- heat. The locomotive is equipped with one or more giant resistor packs to form a load. They become very hot, and are therefore mounted on the outside of the locomotive. Often, there are grilles and fans to cool the resistors, which are also known as dynamic brake grids.
On many locomotive designs, particularly in the United States, dynamic brakes were an optional extra. When fitted, an additional bulge was made in the locomotive body to house them -- this is called a dynamic brake blister.
Dynamic brakes are particularly popular on railroads operating in mountainous terrain. They're an extra, 'free' form of braking independent of the train air brake or the locomotive's own wheel brakes. They don't use up compressed air and thus don't detract from other methods of braking; they're much easier to control than the train air brake; they don't heat up and fade or wear out; and their effectiveness increases with speed and decreases as the train speed drops. This is a good thing because it acts as a natural speed governor and also means that one cannot 'flat spot' the locomotive tires by locking up a wheel.
It's common practice to 'set and forget' the train air brake going down a long grade and then to fine control the speed with the dynamic brake.
On an electric locomotive, one can use the dynamic brake, of course, but a further refinement is possible; pushing the generated power back into the overhead wire instead of wasting it, enabling other trains to be powered from the braking energy. This is known as regenerative braking. It's much easier to achieve with direct current (DC) electrification than alternating current, of course, and that's why some AC electric locomotives have dynamic brakes, not regenerative brakes.