Sure !
The trick is to create a Tensor that contains all the indices of one dimension, then add them element-wise.
The view / expand trick is used to reduce memory usage. By only having one of these Tensors to be the full size and all the other ones only the size of the given dimension.