I have a boolean Python list that I’d like to use as a “mask” for a tensor (of the same size as the list), returning the entries of the tensor where the list is true.
For instance, given the list mask = [True, False, True] and the tensor x = Tensor([1, 2, 3]), I would like to get the tensor y = Tensor([1, 3]). In numpy, this would be simply y = x[mask], but in PyTorch indexing tensors with lists is not (yet?) supported.
Moreover, I need an efficient implementation for this slicing, since this would be performed in every forward pass of my model. What do you suggest?
Thank you in advance.