gnadaf:

    for i, (data, targets) in enumerate(loader):
        optimizer.zero_grad()
        output = model(data)
        ....



Try modifying this to:
    for i, batch in enumerate(loader):
        data, targets = batch.text, batch.target
        optimizer.zero_grad()
        output = model(data)
        ....