This looks like an interesting piece of code! But on to your bug, it seems like the classic case of one of theano’s backends not being fully installed, which is a somewhat common issue to deal with.
Try going through this link (which has Mac instructions as well), and tell us if it fixes the problem for you.