I don’t think this exact workflow would be possible as the transformation into a PILImage would break the computation graph and remove the gradients. PIL.Images are using numpy arrays internally, which do not contain gradients.
You could of course reshape the tensor directly, if this would fit your use case, but this would also break the gradients I think.
What is your exact use case?