Create a masked view of a tensor

I have the following tensor:
tensor([[ nan],
[0.2000],
[ nan],
[0.3000],
[0.4000]])

Now I want to get only non-nan values, run some processing on them (keeping same dimension) and get the resulting tensor as my input but with updated non-nan values.
I was thinking just to create a view of that tensor with only non-nan values, so then the changes to the original data will automatically propagate, but I didn’t find how to create a “masked view” of a tensor.