You can just use indices to get your slice:
b, c, h, w = image.size()
horizontal_normal = image[:, :, :, w-1]
horizontal_one_right = image[:, :, :, 1:w-1]
...

I’m not sure, if I just don’t understand the tf.slice operation, but it looks like both horizontal* images have a different width. Shouldn’t horizontal_one_right be sliced as [:, :, :, 1:w]?
If not, you won’t be able to calculate the difference between both sliced images due to different sizes.
Assuming it’s a typo, you could calculate the loss as:
loss = torch.pow(horizontal_normal-horizontal_one_right, 2).sum() / 2. + torch.pow(ver...