code: def keypoint_3d_loss(
      criterion_keypoints,
      pred_keypoints_3d,
      gt_keypoints_3d,
      has_pose_3d,
  ):
      """
      Compute 3D keypoint loss if 3D keypoint annotations are available.
      """
      conf = gt_keypoints_3d[:, :, -1].unsqueeze(-1).clone()
      gt_keypoints_3d = gt_keypoints_3d[:, :, :-1].clone()
      gt_keypoints_3d = gt_keypoints_3d[has_pose_3d == 1]
      conf = conf[has_pose_3d == 1]
      pred_keypoints_3d = pred_keypoints_3d[has_pose_3d == 1]
      if len(gt_keypoints_3d) > 0:
          gt_pelvis = (
              gt_keypoints_3d[:, 2, :] + gt_keypoints_3d[:, 3, :]
          ) / 2
          gt_keypoints_3d = gt_keypoints_3d - gt_pelvis[:, None, :]
          pred_pelvis = (
              pred_keypoints_3d[:, 2, :] + pred_keypoints_3d[:, 3, :]
          ) / 2
          pred_keypoints_3d = (
              pred_keypoints_3d - pred_pelvis[:, None, :]
          )
          return (
              conf
              * criterion_keypoints(pred_keypoints_3d, gt_keypoints_3d)
          ).mean()
      else:
          return paddle.to_tensor([1.0]).fill_(0.0)
  
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 11 for calling a global function with example usage: keypoint_3d_loss(criterion_keypoints, pred_keypoints_3d, gt_keypoints_3d, has_pose_3d) and returns: unknown, paddle