Differentiable image compression operations in PyTorch

During a CNN classification model training while calculating the loss I am applying the encoding jpeg compression on the image in PyTorch. While I call loss.backward() it must also backpropagate through encoding and compression operation performed on the images.

Are those compression algorithms (e.g. encoding and JPEG compression) are differentiable otherwise how to backpropagate the loss gradient through those operations?

If those operations are not differentiable is there any differentiable compression algorithm that exists in PyTorch which performs H.264 encoding and JPEG compression? Any suggestions will be highly helpful.

To the best of my knowledge I don’t think encoding and compression is differentiable out of the box and it seems it’s an ongoing research.