How was self.loss_function implemented

Maybe this?