def forward(self, x):
        """
        Args:
            x (:class:`torch.FloatTensor` [batch size, sequence length, rnn hidden size]): Input to
                apply dropout too.
        """
        if not self.training or not self.p:
            return x
        x = x.clone()
        mask = x.new_empty(1, x.size(1), x.size(2), requires_grad=False).bernoulli_(1 - self.p)
        mask = mask.div_(1 - self.p)
        mask = mask.expand_as(x)
        return x * mask
def forward ( self , x ) : if not self . training or not self . p : return x x = x . clone ( ) mask = x . new_empty ( 1 , x . size ( 1 ) , x . size ( 2 ) , requires_grad = False ) . bernoulli_ ( 1 - self . p ) mask = mask . div_ ( 1 - self . p ) mask = mask . expand_as ( x ) return x * mask
Args:
            x (:class:`torch.FloatTensor` [batch size, sequence length, rnn hidden size]): Input to
                apply dropout too.