That is how MaxUnpool works.
From the docs

MaxPool2d is not fully invertible, since the non-maximal values are lost.
MaxUnpool2d takes in as input the output of MaxPool2d including the indices of the maximal values and computes a partial inverse in which all non-maximal values are set to zero.