Element-wise logical operation and/or

I have set of masks corresponding to 10 different objects from an input image (shapes and sizes below)

masks.shape:  torch.Size([10, 240, 320, 1])
masks[0].shape: torch.Size([240, 320, 1])
masks[0][:,:,0].shape:  torch.Size([240, 320])

How do I produce union (logical or) of the these masks using torch tensor operation? Something along the lines of combining all the masks to develop single mask.

Thank you.

& and | on bool tensors should do the trick.

Thank you, Thomas. Are you saying

masks[0][:,:,0] = masks[0][:,:,0] | masks[1][:,:,0]
masks[0][:,:,0] = masks[0][:,:,0] | masks[2][:,:,0]
masks[0][:,:,0] = masks[0][:,:,0] | masks[3][:,:,0]

and so on until 9 index (or alternatively use the loop)?

This code is running on cuda/GPU. Is there any operation which can be applied to whole stack of tensors (i.e. 10 tensors in this case)? I mean element wise ORing of all 10 tensors

Ah, sorry. In this case min and max would work.