Could you post the code for cumulative_link_loss and if possible the tensors you are passing to it (you can also create dummy random values for them)?
Apparently the torch.gather call throws an invalid indexing error.