The following Python function expands an array along a dimension
def expand(x, dim,copies):
trans_cmd = list(range(0,len(x.shape)))
trans_cmd.insert(dim,len(x.shape))
new_data = x.repeat(copies).reshape(list(x.shape) + [copies]).transpose(trans_cmd)
return new_data
>>x = np.array([[1,2,3],[4,5,6]])
>>x.shape
(2, 3)
>>x_new = expand(x,2,4)
>>x_new.shape
(2,3,4)
>>x_new
array([[[1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3]],
[[4, 4, 4, 4],
[5, 5, 5, 5],
[6, 6, 6, 6]]])
How can this function be replicated in Julia?