I have a function where I input a tensor T of arbitrary degree d which is of size n1 x n2 x ... x nd. I want to output the tensor T(1:r,1:r,...,1:r). In other words, an r x r x ... x r sub-tensor with d number of r's. I'm having difficulty working around the variable number 1:r's. Ideally I'd like to do this without reshaping T if possible.