Solved by pchandrasekaran in post #4 
              
              
                I apologize. The first line is wrong. 
mask_setup = torch.ones(s*s,) #Shape -> [s*s,]

mask = torch.diag(mask_setup) #Shape -> [s*s, s*s]

mask = mask.reshape(s*s, s, s) #Shape -> [s*s, s, s]

The idea is to create a diagonal matrix of size (s * s, s * s) and then reshape it (s*s, s, s).