title: Reshape 3D numpy array with heterogeneous dimensions to 2D numpy array
body: <p>My data is 3D but only the third axis have a knowed dimension and I need to convert it to a 2D array. </p>
  
  <p>Example:  </p>
  
  <pre><code>input = 
  [[[1, 2, 3]],
  
   [[4, 5, 6],
    [7, 8, 9]],
  
   [[1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]]]
  
  input_reshaped = 
  [[1, 2, 3],
   [4, 5, 6],
   [7, 8, 9],
   [1, 2, 3],
   [4, 5, 6],
   [7, 8, 9]]
  </code></pre>
  
  <p>So I have a 3D data in which the first and second dimensions are variable along my dataset and the third one is constant and previous knowed.</p>
  
  <p>Every block in the input are also numpy arrays. I know that I could perform this using numpy.vstack and iterating over first dimension. But I would like to do this reshape in a pythonic way without explicity iterating over my data, if it's possible.</p>
  
  <p>I already tried to perform a list compehension to get the first shape of each block and then sum these values and use it with reshape. Like this:</p>
  
  <pre><code>def myStack(a):
      lengths = [item.shape[0] for item in a]
      common_dim = a[0].shape[1]
      return a.reshape(np.sum(lengths), common_dim)
  </code></pre>
  
  <p>But with the input in the previous example, I get the following error:</p>
  
  <pre><code>ValueError: cannot reshape array of size 3 into shape (6,3)
  </code></pre>
  
  <p>Because the Python seen the input has a numy.array with shape (3,)</p>
  
  <p>Any ideas?</p>
  
  <p>Extra: If possible, making a back transformation in the above conditions would be really awesome!</p>