I have tensors A_{ij} and B_i, and I want to compute the tensor A_{iB_i}. In numpy I can do this via
A_{ij}
B_i
A_{iB_i}
A[np.arange(N), B]