@classmethod
    def get_layer_monitoring_channels_wrapper(cls, name,
                                              get_layer_monitoring_channels):
        @functools.wraps(get_layer_monitoring_channels)
        def outer(self, state_below=None, state=None, targets=None):
            if self._requires_reshape and self.__class__.__name__ == name:
                if self._requires_unmask:
                    if state_below is not None:
                        state_below, state_below_mask = state_below
                    if state is not None:
                        state, state_mask = state
                    if targets is not None:
                        targets, targets_mask = targets
                if state_below is not None:
                    state_below_shape = ([state_below.shape[0] *
                                          state_below.shape[1]] +
                                         [state_below.shape[i]
                                          for i in xrange(2,
                                                          state_below.ndim)])
                    state_below = state_below.reshape(state_below_shape)
                    if self._requires_unmask:
                        state_below = state_below[
                            state_below_mask.flatten().nonzero()
                        ]
                if state is not None:
                    state_shape = ([state.shape[0] *
                                    state.shape[1]] +
                                   [state.shape[i]
                                    for i in xrange(2, state.ndim)])
                    state = state.reshape(state_shape)
                    if self._requires_unmask:
                        state = state[state_mask.flatten().nonzero()]
                if targets is not None:
                    targets_shape = ([targets.shape[0] *
                                      targets.shape[1]] +
                                     [targets.shape[i]
                                      for i in xrange(2, targets.ndim)])
                    targets = targets.reshape(targets_shape)
                    if self._requires_unmask:
                        targets = targets[targets_mask.flatten().nonzero()]
                return get_layer_monitoring_channels(self, state_below, state,
                                                     targets)
            else:  # Not RNN-friendly, but not requiring reshape
                return get_layer_monitoring_channels(self, state_below, state,
                                                     targets)
        return outer
Tests unaligned writes to the download stream from GetObjectMedia.
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/sandbox/rnn/models/mlp_hook.py/RNNWrapper.get_layer_monitoring_channels_wrapper--crossover with--dataset/ETHPy150Open GoogleCloudPlatform/gsutil/gslib/tests/test_daisy_chain_wrapper.py/TestDaisyChainWrapper.testDownloadWithPartialWrite