Oh problem was solved. What i was doing was
After loading data from Imagefolder as
train_data = datasets.ImageFolder('images/train')
and directly passing through the for loop enumerate
for batch, (data, target) in enumerate(train_data):
            output  = model(data, target)

And find out that target type was int
So in order to enumerate it I had to use DataLoader then use it in for loop .
train_loader = torch.utils.data.DataLoader(train_data,  shuffle=True)
Thanks for helping anyway.