Fix the issue described by #106769 (#108340)
Fixes #106769
Align the behavior of the C++ interface with the Python interface
1. Remove some checks in C++ frontend api ,which duplicate with below
https://github.com/pytorch/pytorch/blob/50fa5880e831c0a1d5e0c2469dacfd0b0b8ff85d/aten/src/ATen/native/RNN.cpp#L676-L690
3. Add some checks
4. support 1D
5. Add Test
Pull Request resolved: https://github.com/pytorch/pytorch/pull/108340
Approved by: https://github.com/mikaylagawarecki