Thank you so much. You are right, looping took me 55 minutes (maybe because the tensor was in the GPU) when I used your method, it took me 9 seconds. I am blown away. Sorry for maybe a silly question :). Your answer is very helpful. I have last two little questions that I am missing.

I want to compare b>a and also b > threshold (a floating-point number). As I said earlier, a and b are both in the same tensor in different channels in the second dimension.

So I tried the following and It throws an error. I am stuck here.
x = AAA[0,0,:,:,:] < AAA[0,1,:,:,:] and AAA[0,1,:,:,:].ge(threshold)

print(x.nonzero())
			


I am wondering whether the following line from the code above is safe

x = AAA[0,0,:,:,:] < AAA[0,1,:,:,:]

Or I should just slice the tensor first before comparison like
a = AAA[0,0,:,:,:] 

b = AAA[0,1,:,:,:]

x = a < b

Thank you so much for the whole wonderful PyTorch community