Assuming d_optimizer contains the parameters of D, then d_optimizer.step() is using the gradients of d_loss_real.backward(one) and d_loss_fake.backward(mone) to update the parameters.
Both losses will create gradients in D and these gradients will be accumulated in all parameters of D, which require gradients.
Wasserstein_D = d_loss_real - d_loss_fake is not used to create the gradients in this example, but based on the formula could yield the same gradients as seen here:
torch.manual_seed(2809)
model = models.resnet18()

out_real = model(torch.randn(1, 3, 224, 224))
out_real = out_real.mean()
out_real.backward()

out_fake = model(torch.randn(1, 3, 224, 224))
out_fake = out_fake.mean()
out_fake.backward(torch.ones_like(out_fake) * -1)

print(model.conv1.weight.grad.abs().sum())

torch.manual_seed(2809)
model = models.resnet18()

out_real = model(torch.randn(1, 3, 224, 224))
out_real = out_real.mean()

out_fake = model(torch.randn(1, 3, 224, 224))
out_fake = out_fake.mean()

loss = out_real - out_fake
loss.backward()

print(model.conv1.weight.grad.abs().sum())

You could check the .grad attributes of some layer and compare the value to the current approach and to the gradient created by Wasserstein_D.backward().