The error is raised if you are trying to use more than a single bool value in an if condition:
x = torch.tensor([True, False])
if x:
    print('lala')
# > RuntimeError: Boolean value of Tensor with more than one value is ambiguous

Depending on your use case, you might want to use .any(), .all(), or split the tensor to take different code paths.