(self, output, target)
return F.kl_div(output, model_prob, reduction='sum')
output (FloatTensor): batch_size x n_classes
        target (LongTensor): batch_size
output (FloatTensor): batch_size x n_classes
        target (LongTensor): batch_size
output ( FloatTensor ) : batch_size x n_classes target ( LongTensor ) : batch_size
def forward(self, output, target):
        """
        output (FloatTensor): batch_size x n_classes
        target (LongTensor): batch_size
        """
        model_prob = self.one_hot.repeat(target.size(0), 1)
        model_prob.scatter_(1, target.unsqueeze(1), self.confidence)
        model_prob.masked_fill_((target == self.padding_idx).unsqueeze(1), 0)

        return F.kl_div(output, model_prob, reduction='sum')
def forward ( self , output , target ) : model_prob = self . one_hot . repeat ( target . size ( 0 ) , 1 ) model_prob . scatter_ ( 1 , target . unsqueeze ( 1 ) , self . confidence ) model_prob . masked_fill_ ( ( target == self . padding_idx ) . unsqueeze ( 1 ) , 0 ) return F . kl_div ( output , model_prob , reduction = 'sum' )