This implementation is done by modifying a publicly available code of HMCs from the work:

James A. Brofos and Roy R. Lederman. Evaluating the implicit midpoint integrator for Riemannian
manifold Hamiltonian Monte Carlo. ICML, 2021.