Motion Only (Local) Bundle Adjustment - Camera pose optimization

Are there any direct implementation on OpenCV for Motion Bundle Adjustment like the one here:

https://de.mathworks.com/help/vision/ref/bundleadjustmentmotion.html#responsive_offcanvas

If not, can someone give a python code example of how to solve it e.g. using cv.LMSolver / scipy.optimize.least_squares, given the 3dXYZPoints, 2dFeaturePoints from Image pair, the estimated pose (obtained by PnP), and CameraIntrinsics Matrix.

Thanks alot!