def check_inf_nan(self, loss):
    if ((loss == float('inf')) or (loss == float('-inf')) or (loss != loss)):
        raise FloatingPointError(f'Loss is infinity or NaN: {loss}')
def check_inf_nan(self, loss):
    if ((loss == float('inf')) or (loss == float('-inf')) or (loss != loss)):
        raise FloatingPointError(f'Loss is infinity or NaN: {loss}')