Is it possible to slice a tensor with another tensor like this?

This is what I am trying to do.

tensor_A[:, tensor_B]

torch::Tensor cholesky_vector = torch::ones({5, 6});
torch::Tensor cholesky_diag_index = torch::arange(da, torch::dtype(torch::kLong)) + 1;
torch::Tensor cholesky_diag_index_2 = (cholesky_diag_index * (cholesky_diag_index + 1)) / 2 - 1;

int main () {
std::cout << cholesky_vector.index({ Slice(None, cholesky_diag_index_2.to(torch::kLong)) });
}

cholesky_vector is tensor_A and cholesky_diag_index_2 is tensor_B.

I’m getting

/home/iii/tor/m_gym/multiv_normal.cpp:54:39: error: no matching function for call to ‘at::Tensor::index(<brace-enclosed initializer list>)’
   54 |     std::cout << cholesky_vector.index({ Slice(None, cholesky_diag_index_2.to(torch::kLong)) });
      |                  ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/iii/tor/m_gym/libtorch/include/ATen/core/Tensor.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/ATen/Tensor.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/function_hook.h:3,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/cpp_hook.h:2,
                 from /home/iii/tor/m_gym/libtorch/include/torch/csrc/autograd/variable.h:6,

etc.

I am able to index with the second tensor, but I am not able to use it at all with Slice. Would I be able to maybe convert the tensor to a list or array or something that the slice would not have a problem with?

Slice wants an int there so I believe you need to .item<int>() the tensor location that contains the int.