[fix] add range check for `k` kthvalue_cpu (#68863)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/68813
Long-term it might make more sense to port it to structured
Pull Request resolved: https://github.com/pytorch/pytorch/pull/68863
Reviewed By: H-Huang
Differential Revision: D32749372
Pulled By: mruberry
fbshipit-source-id: 85a1b2a31e922ff1df0d0f3f576ad219e652aa49