code: def keypoint_2d_loss(
      criterion_keypoints,
      pred_keypoints_2d,
      gt_keypoints_2d,
      has_pose_2d,
  ):
      """
      Compute 2D reprojection loss if 2D keypoint annotations are available.
      The confidence (conf) is binary and indicates whether the keypoints exist or not.
      """
      conf = gt_keypoints_2d[:, :, -1].unsqueeze(-1).clone()
      loss = (
          conf
          * criterion_keypoints(
              pred_keypoints_2d, gt_keypoints_2d[:, :, :-1] * 0.001
          )
      ).mean()
      return loss
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from itertools import cycle, islice
  from collections import abc
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.core.workspace import register, serializable
  from ppdet.utils.logger import setup_logger
label_desc: Use image node_id 10 for calling a global function with example usage: keypoint_2d_loss(criterion_keypoints, pred_keypoints_2d, gt_keypoints_2d, has_pose_2d) and returns: loss