It seems batch_x and batch_y might be a tuple instead of a tensor.
Could you check the type and shapes of both objects?
PS: Variables are deprecated since PyTorch 0.4.0 and you should use tensors directly in newer versions.