A function can be optimized, even if it has two inputs!
First, note that the problem in question already occurs with traditional GANs as well. It might be easier to understand what is going on if you have an 'implementation' example. You can check my tutorial on GANs on GitHub.
Specifically, for training the discriminator we indeed take to inputs:
- A batch of synthetic samples $\hat x$. This we can create by taking a batch of noise vectors, which we pass through the generator ($\hat x = G(z)$).
- A batch of real training samples $x$ from the dataset.
Now we pass both through the discriminator. Obtaining both $D(\hat x)$ and $D(x)$.
Now we can calculate the loss for both outputs and combining them. For WGAN, this means taking the mean over the outputs, and subtracting them, so $mean(D(x)) - mean(D(\hat x))$. This we can backpropagate, as it is simply one number. Note that backpropagating one of these terms (i.e. just $mean(D(x))$ ) is very similar to backpropagating both of them, as it is only one addition operation different. You need just the same amount of calculus for the one as for the other.