def sample(self, state_below=None, state_above=None, layer_above=None,
               theano_rng=None):

        if theano_rng is None:
            raise ValueError("theano_rng is required; it just defaults to " +
                             "None so that it may appear after layer_above " +
                             "/ state_above in the list.")

        if state_above is not None:
            msg = layer_above.downward_message(state_above, for_sampling=True)
        else:
            msg = None

        if self.requires_reformat:
            state_below = self.input_space.format_as(state_below,
                                                     self.desired_space)

        z = T.dot(state_below, self.ising_weights(for_sampling=True)) + \
            self.ising_b(for_sampling=True)

        if msg is not None:
            z = z + msg

        on_prob = T.nnet.sigmoid(2. * self.beta * z)

        samples = theano_rng.binomial(p=on_prob, n=1, size=on_prob.shape,
                                      dtype=on_prob.dtype) * 2. - 1.

        return samples
.. todo::
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/models/dbm/ising.py/BoltzmannIsingHidden.sample