Create a masked view of a tensor

I have the following tensor:
tensor([[ nan],
[ nan],

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.