code: def forward(self, x1, x2, target):
      similarity = paddle.sum(x1 * x2, axis=-1) / (
          paddle.norm(x1, axis=-1) * paddle.norm(x2, axis=-1)
          + self.epsilon
      )
      one_list = paddle.full_like(target, fill_value=1)
      out = paddle.mean(
          paddle.where(
              paddle.equal(target, one_list),
              1.0 - similarity,
              paddle.maximum(
                  paddle.zeros_like(similarity),
                  similarity - self.margin,
              ),
          )
      )
  
      return out
  
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 CosineEmbeddingLoss obj's underlying member method code with example usage: obj.forward(x1, x2, target) and returns: out