rewrote BCECriterion for CUDA compat