def _corrupt(self, x):
        """
        Treats each row in matrix as a multinomial trial.

        Parameters
        ----------
        x : tensor_like
            x must be a matrix where all elements are non-negative
            (with at least one non-zero element)
        Returns
        -------
        y : tensor_like
            y will have the same shape as x. Each row in y will be a
            one hot vector, and can be viewed as the outcome of the
            multinomial trial defined by the probabilities of that row
            in x.
        """
        normalized = x / x.sum(axis=1, keepdims=True)
        return self.s_rng.multinomial(pvals=normalized, dtype=theano.config.floatX)
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/corruption.py/MultinomialSampler._corrupt/original