Solved by Poisson_Chasseur in post #2 
              
              
                After more research, I found that solution that is faster than the first one for the assignation of values in the tensor, but will use the first solution found to create the vector that contain the values. Like in this example with a 4D tensor: 
shape_to_use = [2,3,4,5]; # Change it to 4D tensor wit…