(self, x, y, x_mask)
return alpha
x = batch * len * h1
        y = batch * h2
        x_mask = batch * len
x = batch * len * h1
        y = batch * h2
        x_mask = batch * len
x = batch * len * h1 y = batch * h2 x_mask = batch * len
def forward(self, x, y, x_mask):
        """
        x = batch * len * h1
        y = batch * h2
        x_mask = batch * len
        """
        Wy = self.linear(y) if self.linear is not None else y
        xWy = x.bmm(Wy.unsqueeze(2)).squeeze(2)
        xWy.data.masked_fill_(x_mask.data, -float('inf'))
        if self.training:
            # In training we output log-softmax for NLL
            alpha = F.log_softmax(xWy)
        else:
            # ...Otherwise 0-1 probabilities
            alpha = F.softmax(xWy)
        return alpha
def forward ( self , x , y , x_mask ) : Wy = self . linear ( y ) if self . linear is not None else y xWy = x . bmm ( Wy . unsqueeze ( 2 ) ) . squeeze ( 2 ) xWy . data . masked_fill_ ( x_mask . data , - float ( 'inf' ) ) if self . training : # In training we output log-softmax for NLL alpha = F . log_softmax ( xWy ) else : # ...Otherwise 0-1 probabilities alpha = F . softmax ( xWy ) return alpha