I don’t see any indexing operation in the code snippet and the error message points to:
torch.squeeze(Delta[:,i:i+1,:])

Could you print i before trying to index Delta with it and make sure it’s a scalar value?