I've imported a motion capture armature from an fbx file, the problem is whenever I check the action number of keyframes for any fcurve they are much more than I expected from previewing the action keyframes in dope sheet (the action starts at frame 1)

The keyframes timing is not aligned to blender frames as well.

I could fix this manually by selecting all the keyframes in the dope sheet editor, press g to move them then left click, this snaps all keyframes to their correct location in the timeline and when I recalculate the number of keyframes I get the expected number of keyframes.
Is there a way to replicate the same process in python?
Fcurve.evaluate(frame)– batFINGER Jun 12 '21 at 13:20