what does mask_fill in pytorch do here
I have tensor named &quot;k1&quot; which is in shape 3,1,1,9 and also have p1 tensor in shape of 3,7,9,9 and I wanna know what does the line below do?
p1 = p1 .masked_fill(k1== 0, float(&quot;-1e30&quot;))


As the documentation page describes it:

Tensor.masked_fill(mask, value) 
Fills elements of self tensor with value where mask is True. The shape of mask must be broadcastable with the shape of the underlying tensor.

In your case it will place in p1 the value of float(&quot;-1e30&quot;) at the positions where k1 is equal to zero. Since k1 has singleton dimensions its shape will be broadcasted to the shape of p1.
