port topk to structured (#57790)
Summary:
https://github.com/pytorch/pytorch/issues/55070
There are a few places where `const_cast` is used with utility functions shared with unstructured operators.
The RFC says that assigning to the `out` tensor doesn't work, but that seems to be what e.g., `_allocate_or_resize_output_with_indices` seems to do. Does assignment "work" when the tensors are not allocated?
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57790
Reviewed By: bdhirsh
Differential Revision: D28289685
Pulled By: ezyang
fbshipit-source-id: 7027f162581af0bc0f5b750ff4439b0ecb01ec7b