I think it works. I think it would be more straightforward to have something shorter like this instead:
```Python
# pvals is a vector of length num_classes, with each element equal to 1./num_classes
pvals = T.alloc(1. / num_classes, num_classes)
one_hot = self.s_rng.multinomial(size=(num_examples,), pvals=pvals)
```