Solved by yf225 in post #5 
              
              
                Starting from the current nightly build (and PyTorch 1.5 soon), for 
Xbt[0, :, : , : ] = Xm.repeat(10, 1).view(10, 5, (3 + p))

we can write 
using namespace torch::indexing;
Xbt.index_put_({ 0, Slice(), Slice(), Slice() }, Xm.repeat({ 10, 1 }).view({ 10, 5, (3 + p) }));

Here is the general transla…