I just comment out  this line # data = Variable(data)    #unsqueeze(0)
Second i corrected a code by giving correct test_loader. I replaced test_loader.dataset.imgs with test_loader.
Updated Code
import torch
from torch.utils.data import DataLoader

from model import End_to_end
from torch.autograd import Variable
from loss import loss_function
from grid import save_image
from torchvision import datasets, transforms

CUDA = torch.cuda.is_available()
if CUDA:
    model = End_to_end().cuda()
else:
    model = End_to_end()

EPOCHS = 5

tfs = transforms.Compose([
    transforms.Resize((256, 256)),
    transforms.ToTensor(),
])
testset = datasets.ImageFolder(root="/home/khawar/Desktop/End-to-End_IEEE-TVSCT/test/", transform=tfs)
test_loader = DataLoader(testset, batch_size=8, shuffle=True)

model.load_state_dict(torch.load('./checkpoint/model.pth'))


def test(epoch):
    model.eval()
    test_loss = 0
    for i, (data, _) in enumerate(test_loader):
        # data = Variable(data)    #unsqueeze(0)
        final, residual_img, upscaled_image, com_img, orig_im = model(data.cuda())
        test_loss += loss_function(final, residual_img, upscaled_image, com_img, orig_im).data
        if epoch == EPOCHS and i == 0:
            #             save_image(final.data[0],'reconstruction_final',nrow=8)
            #             save_image(com_img.data[0],'com_img',nrow=8)
            n = min(data.size(0), 6)
            print("saving the image " + str(n))
            comparison = torch.cat([data[:n], final[:n].cpu()])
            comparison = comparison.cpu()
            #             print(comparison.data)
            save_image(com_img[:n].data, 'compressed_' + str(epoch) + '.png', nrow=n)
            save_image(comparison.data, 'reconstruction_' + str(epoch) + '.png', nrow=n)

    test_loss /= len(testset.test_loader)
    print('====> Test set loss: {:.4f}'.format(test_loss))


def save_images():
    epoch = EPOCHS
    model.eval()
    test_loss = 0
    for i, (data, _) in enumerate(test_loader):
        # print(data)
        # data = Variable(data) #unsqueeze(0)
        print(data.shape)
        print(data.size())
        final, residual_img, upscaled_image, com_img, orig_im = model(data.cuda())
        test_loss += loss_function(final, residual_img, upscaled_image, com_img, orig_im).data
        if i == 3:
            #             save_image(final.data[0],'reconstruction_final',nrow=8)
            #             save_image(com_img.data[0],'com_img',nrow=8)
            n = min(data.size(0), 6)
            print("saving the image " + str(n))
            comparison = torch.cat([data[:n], final[:n].cpu()])
            comparison = comparison.cpu()
            #             print(comparison.data)
            save_image(com_img[:1].data, './compressed_image/compressed_' + str(i) + '.png', nrow=n)
            save_image(final[:1].data, './final_image/final_' + str(epoch) + '.png', nrow=n)
            save_image(orig_im[:1].data, './orginal_image/original_' + str(epoch) + '.png', nrow=n)

    test_loss /= len(test_loader.dataset)
    print('====> Test set loss: {:.4f}'.format(test_loss))


save_images()


Error.
/home/khawar/anaconda3/envs/End-to-End_IEEE-TVSCT/bin/python /home/khawar/Desktop/End-to-End_IEEE-TVSCT/test.py
torch.Size([8, 3, 256, 256])
torch.Size([8, 3, 256, 256])
/home/khawar/anaconda3/envs/End-to-End_IEEE-TVSCT/lib/python3.5/site-packages/torch/nn/_reduction.py:43: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
  warnings.warn(warning.format(ret))
/home/khawar/anaconda3/envs/End-to-End_IEEE-TVSCT/lib/python3.5/site-packages/torch/nn/modules/loss.py:432: UserWarning: Using a target size (torch.Size([8, 3, 32, 32])) that is different to the input size (torch.Size([8, 3, 256, 256])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
  return F.mse_loss(input, target, reduction=self.reduction)
Traceback (most recent call last):
  File "/home/khawar/Desktop/End-to-End_IEEE-TVSCT/test.py", line 77, in <module>
    save_images()
  File "/home/khawar/Desktop/End-to-End_IEEE-TVSCT/test.py", line 60, in save_images
    test_loss += loss_function(final, residual_img, upscaled_image, com_img, orig_im).data
  File "/home/khawar/Desktop/End-to-End_IEEE-TVSCT/loss.py", line 7, in loss_function
    com_loss = nn.MSELoss(size_average=False)(orig_img, final_img)
  File "/home/khawar/anaconda3/envs/End-to-End_IEEE-TVSCT/lib/python3.5/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/khawar/anaconda3/envs/End-to-End_IEEE-TVSCT/lib/python3.5/site-packages/torch/nn/modules/loss.py", line 432, in forward
    return F.mse_loss(input, target, reduction=self.reduction)
  File "/home/khawar/anaconda3/envs/End-to-End_IEEE-TVSCT/lib/python3.5/site-packages/torch/nn/functional.py", line 2538, in mse_loss
    ret = (input - target) ** 2
RuntimeError: The size of tensor a (256) must match the size of tensor b (32) at non-singleton dimension 3

Process finished with exit code 1