Optimal learning of quantum Hamiltonians from high-temperature Gibbs states