def _make_or_get_compiled(self, indices, clamped=False):
        """
        Compiles, wraps, and caches Theano functions for non-symbolic calls
        to get_samples.

        Parameters
        ----------
        indices : WRITEME
        clamped : WRITEME
        """
        def compile_f_init():
            mb = T.matrices(len(indices))
            zipped = safe_zip(indices, mb)
            f_init = theano.function(mb,
                                     self._set_activations(zipped, corrupt=True),
                                     allow_input_downcast=True)
            # handle splitting of concatenated data
            def wrap_f_init(*args):
                data = f_init(*args)
                length = len(data) / 2
                return data[:length], data[length:]
            return wrap_f_init

        def compile_f_step():
            prev = T.matrices(self.nlayers)
            if clamped:
                _initial = T.matrices(len(indices))
                _clamps = T.matrices(len(indices))

                z = self._update(copy.copy(prev),
                                 clamped=safe_zip(indices, _initial, _clamps),
                                 return_activations=True)
                f = theano.function(prev + _initial + _clamps, z,
                                    on_unused_input='ignore',
                                    allow_input_downcast=True)
            else:
                z = self._update(copy.copy(prev), return_activations=True)
                f = theano.function(prev, z, on_unused_input='ignore',
                                    allow_input_downcast=True)

            def wrapped(*args):
                data = f(*args)
                length = len(data) / 2
                return data[:length], data[length:]

            return wrapped

        # things that require re-compiling everything
        state = (self._corrupt_switch, self._sample_switch, self._bias_switch)

        if hasattr(self, '_compiled_cache') and state == self._compiled_cache[0]:
            # already have some cached functions

            if indices == self._compiled_cache[1]:
                # everything is cached, return all but state and indices
                return self._compiled_cache[2:]
            else:
                # indices have changed, need to recompile f_init
                f_init = compile_f_init()
                cc = self._compiled_cache
                self._compiled_cache = (state, indices, f_init, cc[3])
                return self._compiled_cache[2:]
        else:
            # have no cached function (or incorrect state)
            f_init = compile_f_init()
            f_step = compile_f_step()
            self._compiled_cache = (state, indices, f_init, f_step)
            return self._compiled_cache[2:]