Solved by Oli in post #2 
              
              
                Pytorch tensors can share the same memory. If you create a tensor once and put that many times into mask_miss this sort of thing can happen. 
It works the same way in numpy if you’re curious. Could you show us how you create the mask_miss tensor?