If it helps, this loop does what I want, but I feel like there is a pytorch way to do what I want without a loop:
C = []
for x in range(len(B)):
CPrime= []
for y in range(len(B[x])):
if B[x][y]!=-1:
CPrime.append(A[x])
else:
CPrime.append(A[-1])
C.append(torch.stack(CPrime))
C = torch.stack(C)
(Sorry for formatting, I’m new to the forums)
where(B!=1, A, A[-1]) would be what I want, but this doesnt work because A is 3 dimensional and B is two dimensional