title: Numpy multidimensional indexing for np.ufunc.at and np.ix_
body: <p>I would like to know how I can take index from an array and multiply with another array. I have two 4d arrays and one 2d index array:</p>
  <pre><code>base = np.ones((2, 3, 5, 5))
  to_multiply = np.arange(120).reshape(2, 3, 4, 5)
  index = np.array([[0, 2, 4, 2], [0, 3, 3, 2]])
  </code></pre>
  <p>The row index of the index array corresponds to the 1st dimension of base and to_multiply, and the value of the index array corresponds to the 3rd dimension of base. I want to take the slice from base according to the index and multiply with to_multiply.</p>
  <p>Using for loops and np.multiply.at (because I may have same index) I can achieve it by:</p>
  <pre><code>for i, x in enumerate(index):
      np.multiply.at(base[i, :, :, :], np.s_[:, x, :], to_multiply[i, :, :, :])
  </code></pre>
  <p>The correctness of above can be validated by:</p>
  <pre><code>to_multiply[0, 0, :, 0]
  array([ 0,  5, 10, 15])
  
  base[0, 0, :, 0]
  array([ 0.,  1., 75.,  1., 10.])
  </code></pre>
  <p><strong>However, I would like to know if there is one-line solution using np.multiply.at and np.ix_</strong></p>
  <p>I tried to use np.ix_ but I'm very confused about it because in this case it's multidimensional.</p>