Thank you very much @tom. Indeed, it compiled fine when I changed to tensor.index({index}).
I copied the related note from the link you sent here, just for anyone having the same problem.

This will break backwards compatibility for the C++ API. There is no implicit conversion from ArrayRef (which was the old argument type) to List<optional>. One common call pattern is tensor.index({indices_tensor}), where indices_tensor is another Tensor, and that will continue working because the {} initializer_list constructor for List<optional> can take Tensor elements that are implicitly converted to optional, but another common call pattern was tensor.index(indices_tensor), where previously, the Tensor got implicitly converted to an ArrayRef, and to implicitly convert Tensor → optional → List<optional> would be two implicit conversions. C++ doesn’t allow chaining. two implicit conversions. So those call sites have to be rewritten to tensor.index({indices_tensor}).