Add a mode to docgen to run the code samples in the documentation.

This alleviates copying them elsewhere to ensure they are not broken.

For the moment most of the "tests" fail due to various problems.  I fixed the the `library/tensor/basic.txt` file as a sample of the work that would have to be done to make this work for all the documentation.

If there is interest in this I can either work on it in this branch and merge when it's over or merge this right away to allow others to help.

When we get to a state where those tests pass we can think of adding such a test run to the buildbot and/or travis to check for broken examples and remove the test_tutorial files.
Yes we integrate the resulting images (from a manual run).  It would be a major pain to rework that code so that the images are generated live for the documentation we build, which is why I disabled them for now (that and the examples aren't coherent about what is train, predict and the others).