Extracting a submatrix from a matrix

Given a 2-d tensor x, 1-d index tensors I and J, I knew of the way of extracting submatrix as x[I][:, J] which works.

But at python - Numpy extract submatrix - Stack Overflow I also found for NumPy a way of x[I[:, None], J[None, :]]. This seems to also work for PyTorch. Is it documented anywhere? Is it officially supported?

Which way is more performant in terms of extra allocations? (the first way would seem to reallocate first x[I], but I don’t know if the second way does any hidden reallocations due to the index broadcasting)