THOR: A Generic Energy Estimation Approach for On-Device Training