def METHOD_NAME(self, hs_pad, hlens, ys_pad, ys_lens):
    """Calculate CTC loss.
    Args:
        hs_pad: batch of padded hidden state sequences (B, Tmax, D)
        hlens: batch of lengths of hidden state sequences (B)
        ys_pad: batch of padded character id sequence tensor (B, Lmax)
        ys_lens: batch of lengths of character sequence (B)
    """
    # hs_pad: (B, L, NProj) -> ys_hat: (B, L, Nvocab)
    ys_hat = self.ctc_lo(F.dropout(hs_pad, p=self.dropout_rate))
    if self.ctc_type == "gtnctc":
        # gtn expects list form for ys
        ys_true = [y[y != -1] for y in ys_pad]  # parse padded ys
    else:
        # ys_hat: (B, L, D) -> (L, B, D)
        ys_hat = ys_hat.transpose(0, 1)
        # (B, L) -> (BxL,)
        ys_true = torch.cat([ys_pad[i, :l] for i, l in enumerate(ys_lens)])
    loss = self.loss_fn(ys_hat, ys_true, hlens, ys_lens).to(
        device=hs_pad.device, dtype=hs_pad.dtype
    )
    return loss