Either slice() or narrow() (https://pytorch.org/docs/stable/torch.html#torch.narrow 112, https://github.com/pytorch/pytorch/blob/b2dde4386adf110262203a57d8cc552309be0e27/aten/src/ATen/core/Tensor.h#L441 68) should work. If x0 is a single-element tensor, we can use x0.item().toInt() to cast it to int64_t.