Do you think there would be a better way than
In [1]: import torch                                                                                                                  

In [2]: import numpy as np                                                                                                            

In [3]: x = torch.FloatTensor([[1,2],[3,4]]) 
   ...: xx = x.split(1) 
   ...:                                                                                                                               

In [4]: xx                                                                                                                            
Out[4]: (tensor([[1., 2.]]), tensor([[3., 4.]]))

In [5]: out = torch.FloatTensor([]) 
   ...:  
   ...: for x_sub, num_repeat in zip(xx, [1,2]): 
   ...: ^Iout = torch.cat([out, x_sub.expand(num_repeat, -1)]) 
   ...:                                                                                                                               

In [6]: out                                                                                                                           
Out[6]: 
tensor([[1., 2.],
        [3., 4.],
        [3., 4.]])

In [7]: x = np.array([[1,2],[3,4]])                                                                                                   

In [8]: np.repeat(x, [1,2], axis=0)                                                                                                   
Out[8]: 
array([[1, 2],
       [3, 4],
       [3, 4]])

Is this work for sure with backpropagation ?