How to change the tensor value in c++?

In Pytorch

import torch

temp_data = torch.tensor([1, 2, 3, 4])  

# temp_data = tensor([1, 2, 3, 4])

temp_data[0] = 5

# temp_data = tensor([5, 2, 3, 4])

So how can something similar be done in c++??

Thanks a lot.

tensor.index_put_ would be the right approach as given in these docs.

Thank you for your help :grinning:@ptrblck