def METHOD_NAME(self, real_pred, real_img):
    grad_real, = autograd.grad(
        outputs=real_pred.sum(), inputs=real_img, create_graph=True)
    grad_penalty = grad_real.pow(2).view(grad_real.shape[0],
                                         -1).sum(1).mean()
    return grad_penalty