I found a good way
at::Tensor at::index_select(const at::Tensor &self, at::Dimname dim, const at::Tensor &index)

torch::Tensor a = at::index_select(torch::Tensor data, torch::Tensor index)

But there’s still a problem.
error : no matching function for call to 'index_select(at::Tensor&, at::Tensor$)'

Maybe this method takes three arguments， But How to get dim???
Thanks.