Tensor index: too many indices for tensor of dimension, but tolist work

A and B is tensor
A[B] will cause error: IndexError: too many indices for tensor of dimension 4

but A[B.tolist()] is work.

How can I solve the problem?