def SoftCrossEntropy(inputs, target, weight_id=None, reduction='sum'):
     """
     inputs are performed by log_softmax
     """
     log_likelihood = -inputs

     batch = inputs.shape[0]

     if weight_id is None:
         if reduction == 'average':
             loss = torch.sum(torch.mul(log_likelihood, target)) / batch
         else:
             loss = torch.sum(torch.mul(log_likelihood, target))
         return loss
     else:
         log_likelihood = log_likelihood * weight_id
         target = target * weight_id
         if reduction == 'average':
             loss = torch.sum(torch.mul(log_likelihood, target)) / batch
         else:
             loss = torch.sum(torch.mul(log_likelihood, target))
         return loss