tv_loss += loss.tvLoss(img)
File "/home/project/network.py", line 169, in tvLoss
vertical = torch.abs(img[:, :, 1:, :] - img[:, :, :-1, :])
TypeError: list indices must be integers or slices, not tuple

You would still need to index the list in a single dimension as seen here:

l = [torch.randn(2) for _ in range(4)]
print(l)
# [tensor([ 0.3270, -2.2517]), tensor([-0.2995, -0.1264]), tensor([ 0.1325, -0.0489]), tensor([-1.1356, -0.3686])]
print(l[0])
# tensor([ 0.3270, -2.2517])
print(l[-1])
# tensor([-1.1356, -0.3686])
print(l[:, 0])
# TypeError: list indices must be integers or slices, not tuple