code: def _calc_distances(preds, targets, mask, normalize):
      """Calculate the normalized distances between preds and target.
  
      Note:
          batch_size: N
          num_keypoints: K
          dimension of keypoints: D (normally, D=2 or D=3)
  
      Args:
          preds (np.ndarray[N, K, D]): Predicted keypoint location.
          targets (np.ndarray[N, K, D]): Groundtruth keypoint location.
          mask (np.ndarray[N, K]): Visibility of the target. False for invisible
              joints, and True for visible. Invisible joints will be ignored for
              accuracy calculation.
          normalize (np.ndarray[N, D]): Typical value is heatmap_size
  
      Returns:
          np.ndarray[K, N]: The normalized distances. \
              If target keypoints are missing, the distance is -1.
      """
      N, K, _ = preds.shape
      # set mask=0 when normalize==0
      _mask = mask.copy()
      _mask[np.where((normalize == 0).sum(1))[0], :] = False
      distances = np.full((N, K), -1, dtype=np.float32)
      # handle invalid values
      normalize[np.where(normalize <= 0)] = 1e6
      distances[_mask] = np.linalg.norm(
          ((preds - targets) / normalize[:, None, :])[_mask], axis=-1
      )
      return distances.T
  
imports: import cv2
  import numpy
  import paddle.nn.functional
label_desc: Use image node_id 16 for calling a global function with example usage: _calc_distances(preds, targets, mask, normalize) and returns: distances