thanks a lot, K. Frank
If I define loss function in another way which will be inherited from nn.Module, must I use torch functions in all forward steps?
class CrpsLossModule(nn.Module):
def init(self, nClass, reduce=True):
super(CrpsLossModule, self).init()
self.nClass = nClass
self.reduce = reduce
def forward(self, outEjectF, targetEjectF):
    
    # forward code here

    if self.reduce:
        return torch.mean(F_loss)
    else:
        return F_loss