code: def apply_single(self, pred, tagmap):
      if tagmap.numpy()[:, :, 3].sum() == 0:
          return (paddle.zeros([1]), paddle.zeros([1]))
      nonzero = paddle.nonzero(tagmap[:, :, 3] > 0)
      if nonzero.shape[0] == 0:
          return (paddle.zeros([1]), paddle.zeros([1]))
      p_inds = paddle.unique(nonzero[:, 0])
      num_person = p_inds.shape[0]
      if num_person == 0:
          return (paddle.zeros([1]), paddle.zeros([1]))
  
      pull = 0
      tagpull_num = 0
      embs_all = []
      person_unvalid = 0
      for person_idx in p_inds.numpy():
          valid_single = tagmap[person_idx.item()]
          validkpts = paddle.nonzero(valid_single[:, 3] > 0)
          valid_single = paddle.index_select(valid_single, validkpts)
          emb = paddle.gather_nd(pred, valid_single[:, :3])
          if emb.shape[0] == 1:
              person_unvalid += 1
          mean = paddle.mean(emb, axis=0)
          embs_all.append(mean)
          pull += paddle.mean(paddle.pow(emb - mean, 2), axis=0)
          tagpull_num += emb.shape[0]
      pull /= max(num_person - person_unvalid, 1)
      if num_person < 2:
          return pull, paddle.zeros([1])
  
      embs_all = paddle.stack(embs_all)
      A = embs_all.expand([num_person, num_person])
      B = A.transpose([1, 0])
      diff = A - B
  
      diff = paddle.pow(diff, 2)
      push = paddle.exp(-diff)
      push = paddle.sum(push) - num_person
  
      push /= 2 * num_person * (num_person - 1)
      return pull, push
  
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 numpy
  import paddle
  import paddle.nn
  from ppdet.core.workspace import register, serializable
label_desc: Use image node_id 2 for calling the AELoss obj's underlying member method code with example usage: obj.apply_single(pred, tagmap) and returns: pull,  push, paddle,  paddle, paddle,  paddle, paddle,  paddle, pull,  paddle