Would the latter include not only CUDA/Cpu but also the device that xy is on?

Yes
in that case which device will be used in the first case?

The current CUDA device (if xy is a CUDA tensor). You can set the device with DeviceGuard in C++ or torch.cuda.set_device in Python.