IndexError: too many indices for tensor of dimension

IndexError: too many indices for tensor of dimension 2

As the error message describes, you are trying to index a tensor with too many indices. Here is a small example:

x = torch.randn(3, 4)
x[0, 0, 0]
# IndexError: too many indices for tensor of dimension 2