@classmethod
    def fprop_wrapper(cls, name, fprop):
        @functools.wraps(fprop)
        def outer(self, state_below, return_all=False):
            if self._requires_reshape:
                if self._requires_unmask:
                    state_below, mask = state_below
                if isinstance(state_below, tuple):
                    ndim = state_below[0].ndim
                    reshape_size = state_below[0].shape
                else:
                    ndim = state_below.ndim
                    reshape_size = state_below.shape

                if ndim > 2:
                    if isinstance(state_below, tuple):
                        inp_shape = ([[state_below[j].shape[0] *
                                       state_below[j].shape[1]] +
                                      [state_below[j].shape[i]
                                      for i in xrange(2, state_below[j].ndim)]
                                      for j in xrange(len(state_below))])
                        reshaped_below = ()
                        for i in xrange(len(state_below)):
                            reshaped_below +=\
                                (state_below[i].reshape(inp_shape[i]),)
                    else:
                        inp_shape = ([state_below.shape[0] *
                                      state_below.shape[1]] +
                                     [state_below.shape[i]
                                     for i in xrange(2, state_below.ndim)])
                        reshaped_below = state_below.reshape(inp_shape)
                    reshaped = fprop(self, reshaped_below)
                    if isinstance(reshaped, tuple):
                        output_shape = ([[reshape_size[0],
                                          reshape_size[1]] +
                                         [reshaped[j].shape[i]
                                          for i in xrange(1, reshaped[j].ndim)]
                                         for j in xrange(len(reshaped))])
                        state = ()
                        for i in xrange(len(reshaped)):
                            state += (reshaped[i].reshape(output_shape[i]),)
                    else:
                        output_shape = ([reshape_size[0],
                                         reshape_size[1]] +
                                        [reshaped.shape[i]
                                         for i in xrange(1, reshaped.ndim)])
                        state = reshaped.reshape(output_shape)
                else:
                    state = fprop(self, state_below)
                if self._requires_unmask:
                    return (state, mask)
                else:
                    return state
            else:  # Not RNN-friendly, but not requiring reshape
                if return_all:
                    return fprop(self, state_below, return_all)
                else:
                    return fprop(self, state_below)
        return outer
Convert the group id to the group name on this system
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/sandbox/rnn/models/mlp_hook.py/RNNWrapper.fprop_wrapper--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/gid_to_group