Add general fallback for rem2pi (#52955)
**Overview:**
- This PR fixes #44715 by adding a general fallback.
**Testing:**
- Tested the updated code.
- Verified that other functionalities remain unaffected.
**Dependencies:**
- No dependencies on other pull requests.
**CC:**
- @N5N3
---------
Signed-off-by: 11happy <soni5happy@gmail.com>
Co-authored-by: N5N3 <2642243996@qq.com>