mask1 and mask2 are both boolean tensors filled with some amount of True and False along their 1 dimension.
In response to the second part of your question, in the end, I want A to actually be a mask for another tensor. Specifically, in my problem I have a loss function that outputs a (L,n,L,a) tensor of floats, but many of those values in the tensor I don’t need contributing to the final loss. In order to only have only specific entries contribute to the loss, I’m trying to create a mask tensor (A) that is also 4D, which only has True in the particular positions that I want contributing to the loss. I will then multiply the 4D loss tensor and the 4D mask together to zero out the unneeded contributions. Hopefully this clarifies a bit of context.
Here’s also a more concrete example:
L = 100
n = 5
a = 13
A = torch.zeros((L,n,L,a)).bool()
mask1 = torch.randint(0,2,(L,)).bool()
mask2 = torch.randint(0,2,(L,)).bool()
print(A[mask1,0].shape) # works fine
print(A[mask1,0,mask2,:3]) # error