Maybe this includes torch bug.
This message caused in aten/src/ATen/native/LossCTC.cpp at line 86
Real message I think is

RuntimeError: Expected tensor to have size at least {‘max(prob.shape[0])’} at dimension 1, but got size {‘length_input[index]’} for argument #2 ‘log_probs’ (while checking arguments forctc_loss_gpu)

And error is caused because you set number bigger than prob.shape[0] for length_input.
You need to set number of input length.