Implement custom loss functions

I would like to implemnt the below loss function based on WGAN-gp loss function. How can I do that?

encoder

Decoder