Why does iPad run out of batteries while it's plugged in?
The 12.9" iPad Pro can use power faster than the 12W power adapter can supply it. That's why it can run out of power when running for example a game, even though it is connected to the charger.

To avoid that, use the 29W Apple power adapter instead. The 29W adapter is not supplied with the iPad Pro, but must be bought seperately.