You claim that it's possible to tell how much energy was used to produce a block minting solution given the difficulty. It is not.
If you actually mined you would know that no two miners use the same amount of energy for a given hash rate and also you would know that it's possible to come up with the solution too early or too late entirely through luck and therefore you can't directly estimate how much energy was used to produce a result. All estimates of how much energy the bitcoin network uses are completely made up and should not be trusted.
> If you actually mined you would know that no two miners use the same amount of energy for a given hash rate
True but irrelevant: The upper bound for rentability is the cost of electricity plus the capital cost of the mining equipment.
As soon as the sum of these two exceeds the expected mining reward, rational miners stop mining.
I don't doubt that there are inefficient miners out there, but I strongly suspect the majority to act according to their rational economic self-interest and not as players in an expensive technological lottery.
> it's possible to come up with the solution too early or too late entirely through luck
Yes, but not consistently and therefore also not profitably so. The law of large numbers [1] applies.
It's true you can't predict exactly the energy used in a given block, but you can predict the energy use of blocks on average: this is not very difficult because the energy efficiency of state of the art mining hardware is known, and the difficulty is known.
If you actually mined you would know that no two miners use the same amount of energy for a given hash rate and also you would know that it's possible to come up with the solution too early or too late entirely through luck and therefore you can't directly estimate how much energy was used to produce a result. All estimates of how much energy the bitcoin network uses are completely made up and should not be trusted.