The error is given as:
RuntimeError: Expected 3-dimensional tensor, but got 2-dimensional tensor for argument #1 ‘log_probs’ (while checking arguments for ctc_loss_cpu)

which points to a wrong shape for log_probs.
Checking the docs of nn.CTCLoss gives the expected shape for log_probs as:

Log_probs: Tensor of size (T,N,C), where T=input length, N=batch size, and C=number of classes (including blank). The logarithmized probabilities of the outputs (e.g. obtained with torch.nn.functional.log_softmax()).