you also can put the controls in another custom function to keep the main process function cleaner.
func _physics_process(delta):
motion.y += get_gravity() * delta
check_controls()
motion = move_and_slide(motion, UP)
Animation_Player()
so the custom function check_controls() can contain the lines, that it replaces here.
and it looks like in this situation it´s not needed to pass motion to the animations-function, because it´s declared above all functions (it´s not declared inside process here) and can directly be used inside the animations-function