'list' object has no attribute 'cuda'

Step through with a reasonable batch size and build up the output dataset

model.eval()
outputs = []
for images in test_loader:
# move tensors to GPU if CUDA is available
if train_on_gpu:

    images = images.cuda()
    #images = torch.tensor(images).cuda()
test_output = model({'images': images })

outputs.extend(list(test_output.cpu().detach().numpy().reshape(len(test_output))))

img_names = list( test_df.iloc[:, 0].values)
outputs = [round(x,6) for x in outputs]

output_df = pd.DataFrame({‘Id’: img_names, ‘Pawpularity’: outputs})
output_df.head(10)

#############################################
This is the source code but the error is reported

7 if train_on_gpu:
8
----> 9 images = images.cuda()
10 #images = torch.tensor(images).cuda()
11 test_output = model({‘images’: images })

AttributeError: ‘list’ object has no attribute ‘cuda’
After that I modified the code:
but it makes a new error i dont know how to solve it
#images = images.cuda()
images = torch.tensor(images).cuda()
9 #images = images.cuda()
—> 10 images = torch.tensor(images).cuda()
11 test_output = model({‘images’: images })
12

ValueError: only one element tensors can be converted to Python scalars