code: def ctcloss(self, f_char, tcl_pos, tcl_mask, tcl_label, label_t):
      f_char = paddle.transpose(f_char, [0, 2, 3, 1])
      tcl_pos = paddle.reshape(tcl_pos, [-1, 3])
      tcl_pos = paddle.cast(tcl_pos, dtype=int)
      f_tcl_char = paddle.gather_nd(f_char, tcl_pos)
      f_tcl_char = paddle.reshape(
          f_tcl_char, [-1, 64, self.pad_num + 1]
      )  # len(Lexicon_Table)+1
      f_tcl_char_fg, f_tcl_char_bg = paddle.split(
          f_tcl_char, [self.pad_num, 1], axis=2
      )
      f_tcl_char_bg = f_tcl_char_bg * tcl_mask + (1.0 - tcl_mask) * 20.0
      b, c, l = tcl_mask.shape
      tcl_mask_fg = paddle.expand(
          x=tcl_mask, shape=[b, c, self.pad_num * l]
      )
      tcl_mask_fg.stop_gradient = True
      f_tcl_char_fg = f_tcl_char_fg * tcl_mask_fg + (
          1.0 - tcl_mask_fg
      ) * (-20.0)
      f_tcl_char_mask = paddle.concat(
          [f_tcl_char_fg, f_tcl_char_bg], axis=2
      )
      f_tcl_char_ld = paddle.transpose(f_tcl_char_mask, (1, 0, 2))
      N, B, _ = f_tcl_char_ld.shape
      input_lengths = paddle.to_tensor([N] * B, dtype="int64")
      cost = paddle.nn.functional.ctc_loss(
          log_probs=f_tcl_char_ld,
          labels=tcl_label,
          input_lengths=input_lengths,
          label_lengths=label_t,
          blank=self.pad_num,
          reduction="none",
      )
      cost = cost.mean()
      return cost
  
file_path: PaddleOCR/ppocr/losses/e2e_pg_loss.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from paddle import nn
  import paddle
  from .det_basic_loss import DiceLoss
  from ppocr.utils.e2e_utils.extract_batchsize import pre_process
label_desc: Use image node_id 4 for calling the PGLoss obj's underlying member method code with example usage: obj.ctcloss(f_char, tcl_pos, tcl_mask, tcl_label, label_t) and returns: cost