Solved by zhl515 in post #3 
              
              
                you can use torch. eq ( input ,  other ,  out=None ) → Tensor .But torch.eq() only returns   torch.ByteTensor with (0/1)s not bool vaule. There is another function torch. equal ( tensor1 ,  tensor2 ) → bool, but it doesn’t do broadcasting, only return  a single bool value with shape 1. 
a = torch.te…