Solved by Unity05 in post #4 
              
              
                loss = criterion(output.squeeze(-1), b_y.float()) 
Btw, Variables are deprecated. Nowadays, normal tensors can have gradients as well.