thank you for your reply. But I do  need  to create a new tensor C which C[bi,ni,hi,wi,:]=A[bi,ni,B[bi,ni,hi,wi,0],B[bi,ni,hi,wi,1],:] . In other word , I want to use 2d_index (hi,wi)  to get the value of A[…,hi,wi,…]  and generate a new tensor C , and C.shape=A.shape .