code: def forward(self, predicts, batch):
      targets = batch[1].astype("int64")
      label_lengths = batch[2].astype("int64")
      sem_target = batch[3].astype("float32")
      embedding_vectors = predicts["embedding_vectors"]
      rec_pred = predicts["rec_pred"]
  
      if not self.is_cosin_loss:
          sem_loss = paddle.sum(
              self.loss_sem(embedding_vectors, sem_target)
          )
      else:
          label_target = paddle.ones([embedding_vectors.shape[0]])
          sem_loss = paddle.sum(
              self.loss_sem(embedding_vectors, sem_target, label_target)
          )
  
      # rec loss
      batch_size, def_max_length = targets.shape[0], targets.shape[1]
  
      mask = paddle.zeros([batch_size, def_max_length])
      for i in range(batch_size):
          mask[i, : label_lengths[i]] = 1
      mask = paddle.cast(mask, "float32")
      max_length = max(label_lengths)
      assert max_length == rec_pred.shape[1]
      targets = targets[:, :max_length]
      mask = mask[:, :max_length]
      rec_pred = paddle.reshape(rec_pred, [-1, rec_pred.shape[2]])
      input = nn.functional.log_softmax(rec_pred, axis=1)
      targets = paddle.reshape(targets, [-1, 1])
      mask = paddle.reshape(mask, [-1, 1])
      output = -paddle.index_sample(input, index=targets) * mask
      output = paddle.sum(output)
      if self.sequence_normalize:
          output = output / paddle.sum(mask)
      if self.sample_normalize:
          output = output / batch_size
  
      loss = output + sem_loss * 0.1
      return {"loss": loss}
  
file_path: PaddleOCR/ppocr/losses/rec_aster_loss.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  from paddle import nn
label_desc: Use image node_id 2 for calling the AsterLoss obj's underlying member method code with example usage: obj.forward(predicts, batch) and returns: dict