Total Variation Distance Estimation Is as Easy as Probabilistic Inference