I have a tensor with values I’d like to ignore. Sometimes these values appear in the middle of the tensor. For example, given
tensor([[1, 2, 3, 4, 5],
        [1, 2, 3, 3, 5]])

I might want to ignore 3. Is there some way to filter out the 3s while padding as necessary? For instance,
tensor([[1, 2, 4, 5],
        [1, 2, 5, -1]])

My thought is to use torch.where, but this only updates the tensor’s ignore-value without changing the shape.