User defined loss function