def _corrupt(self, x):
        """
        Corrupts a single tensor_like object.

        Parameters
        ----------
        x : tensor_like
            Theano symbolic representing a (mini)batch of inputs to be
            corrupted, with the first dimension indexing training
            examples and the second indexing data dimensions.

        Returns
        -------
        corrupted : tensor_like
            Theano symbolic representing the corresponding corrupted input.
        """
        num_examples = x.shape[0]
        num_classes = x.shape[1]

        keep_mask = T.addbroadcast(
            self.s_rng.binomial(
                size=(num_examples, 1),
                p=self.corruption_level - 1,
                dtype='int8'
            ),
            1
        )

        # generate random one-hot matrix
        pvals = T.alloc(1.0 / num_classes, num_classes)
        one_hot = self.s_rng.multinomial(size=(num_examples,), pvals=pvals)

        return keep_mask * x + (1 - keep_mask) * one_hot
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/corruption.py/OneHotCorruptor._corrupt/swapped operands of `-`