title: How to get a 2D array containing indices of another 2D array
body: <h3>Problem</h3>
  <pre><code>import numpy as np
  </code></pre>
  <p>I have an an array, <em>without any prior information of its contents</em>. For example:</p>
  <pre><code>ourarray = \
  np.array([[0,1],
            [2,3],
            [4,5]])
  </code></pre>
  <p>I want to get the pairs of numbers which can be used for indexing <code>ourarray</code>. Ie I want to get:</p>
  <pre><code>array([[0, 0, 1, 1, 2, 2],
         [0, 1, 0, 1, 0, 1]])
  </code></pre>
  <p>(<code>0,0</code>, <code>0,1</code>, <code>1,0</code>, etc., all the possible indices of <code>ourarray</code> are in this array.)</p>
  <hr />
  <h3>Similar but different posts</h3>
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/65001287/how-to-find-indices-of-a-2d-numpy-array-occuring-in-another-2d-array">how to find indices of a 2d numpy array occuring in another 2d array</a>: here they search for one array within another one, not returning indices of the entire array.</p>
  </li>
  <li><p><a href="https://stackoverflow.com/questions/64930665/find-indices-of-rows-of-numpy-2d-array-in-another-2d-array">Find indices of rows of numpy 2d array in another 2D array</a>: they are dealing with two arrays to start with, the objective <em>isn't</em> to create a second array based on the first one containing its indices</p>
  </li>
  </ul>
  <hr />
  <h3>Attempt 1 (Successful but inefficient)</h3>
  <p>I can get this array by:</p>
  <pre><code>np.array(np.where(np.ones(ourarray.shape)))
  </code></pre>
  <p>Which gives the desired result but it requires creting <code>np.ones(ourarray.shape)</code>, which seems like not an efficient way of doing it.</p>
  <hr />
  <h3>Attempt 2 (Failed)</h3>
  <p>I also tried:</p>
  <pre><code>np.array(np.where(ourarray))
  </code></pre>
  <p>which does not work because there is no indices returned for the <code>0</code> entry of <code>ourarray</code>.</p>
  <hr />
  <h3>Question</h3>
  <p><strong>Attempt 1 works, but I am looking for a more efficient way. How can I do this more efficiently?</strong></p>