Solved by tr_arun in post #2 
              
              
                Reshape it to 1 d and then find the euclidean distance. 
a = torch.randn(1, 1, 512, 1)

b = troch.randn(1, 1, 512, 1)

euclidena_dist = sum(((a - b)**2).reshape(512))