Thanks for your reply.
No I didn’t implement the __init__ method, I just add __init__ method but it doesn’t work yet.
class MyLoss(Module):
    def __init__(self):
        super(MyLoss, self).__init__()

    def forward(self, x, y):
        d = y - x
        d *= 1 / y.size()[1]
        d = d.abs()
        return torch.sum(d) / y.size()[0]