Details and motivation are described in this paper or tutorial. For your convenience the same code is provided in both python and ipython.
This implementation trains on MNIST, generating reasonable quality samples after less than one minute of training on a single Titan X
When latent dimensionality is 2, we can also visualize the distribution of labels in the feature space.