x = tf.TensorArray(dtype=tf.float32, size=0, dynamic_size=True)
a = tf.ones((2, 3))
b = tf.zeros((2, 3))
x.write(tf.constant(0), a)
x.write(tf.constant(1), b)
>>> list(x.stack())
[<tf.Tensor: shape=(2, 3), dtype=float32, numpy=
array([[1., 1., 1.],
[1., 1., 1.]], dtype=float32)>, <tf.Tensor: shape=(2, 3), dtype=float32, numpy=
array([[0., 0., 0.],
[0., 0., 0.]], dtype=float32)>]
>>> tf.transpose(x.stack(), [0, 2, 1])
<tf.Tensor: shape=(2, 3, 2), dtype=float32, numpy=
array([[[1., 1.],
[1., 1.],
[1., 1.]],
[[0., 0.],
[0., 0.],
[0., 0.]]], dtype=float32)>