title: Rearranging PyTorch tensor in a windowed manner
body: <p>So I have a tensor</p>
  <pre><code>A = torch.tensor([[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]])
  </code></pre>
  <p>and I was hoping to rearrange it in sliding windows, that is,</p>
  <pre><code>f(A) = torch.tensor([[1,2,5,6],[3,4,7,8],[9,10,13,14],[11,12,15,16]])
  </code></pre>
  <p>by viewing every tensor in <code>A</code> as a 2-by-2 small window, and then arranging the &quot;window&quot;s in a 2-by-2 matrix. This operation is similar to <code>ArrayFlatten</code> of Mathematica, but I couldn' find a way to do it in PyTorch. Any help is welcome.</p>