I found some related posts:

https://stackoverflow.com/questions/52946920/bool-value-of-tensor-with-more-than-one-value-is-ambiguous-in-pytorch 31
RuntimeError: bool value of Variable objects containing non-empty torch.LongTensor is ambiguous
RuntimeError: bool value of Tensor with more than one value is ambiguous 32
https://discuss.pytorch.org/t/why-cant-one-pass-data-through-a-torch-relu-module-directly 7