thanks. its a per-batch statistic. I’m open to other suggestions if you’re worried it could be a problem, but at the very least autograd is able to differentiate it. btw, I ended up running torch.mean() on that expression prior to returning it.