I need to implement a custom loss function and looking for best practices on doing so. In the PyTorch documentation, it is clear that the predefined loss functions are implemented as classes. My question is, should I also define my custom loss function as a class or a normal Python function would do? I also would like to know why PyTorch implements losses as classes. Thanks in advance!