code: def __call__(self, image, target):
      kps = target["keypoints"]
      num_kps = kps.shape[0]
      kps_weights = np.ones((num_kps,), dtype=np.float32)
      if "visible" in target:
          visible = target["visible"]
          kps_weights = visible
  
      heatmap = np.zeros(
          (num_kps, self.heatmap_hw[0], self.heatmap_hw[1]),
          dtype=np.float32,
      )
      heatmap_kps = (kps / 4 + 0.5).astype(np.int)  # round
      for kp_id in range(num_kps):
          v = kps_weights[kp_id]
          if v < 0.5:
              # 如果该点的可见度很低，则直接忽略
              continue
  
          x, y = heatmap_kps[kp_id]
          ul = [
              x - self.kernel_radius,
              y - self.kernel_radius,
          ]  # up-left x,y
          br = [
              x + self.kernel_radius,
              y + self.kernel_radius,
          ]  # bottom-right x,y
          # 如果以xy为中心kernel_radius为半径的辐射范围内与heatmap没交集，则忽略该点(该规则并不严格)
          if (
              ul[0] > self.heatmap_hw[1] - 1
              or ul[1] > self.heatmap_hw[0] - 1
              or br[0] < 0
              or br[1] < 0
          ):
              # If not, just return the image as is
              kps_weights[kp_id] = 0
              continue
  
          # Usable gaussian range
          # 计算高斯核有效区域（高斯核坐标系）
          g_x = (
              max(0, -ul[0]),
              min(br[0], self.heatmap_hw[1] - 1) - ul[0],
          )
          g_y = (
              max(0, -ul[1]),
              min(br[1], self.heatmap_hw[0] - 1) - ul[1],
          )
          # image range
          # 计算heatmap中的有效区域（heatmap坐标系）
          img_x = (max(0, ul[0]), min(br[0], self.heatmap_hw[1] - 1))
          img_y = (max(0, ul[1]), min(br[1], self.heatmap_hw[0] - 1))
  
          if kps_weights[kp_id] > 0.5:
              # 将高斯核有效区域复制到heatmap对应区域
              heatmap[kp_id][
                  img_y[0] : img_y[1] + 1, img_x[0] : img_x[1] + 1
              ] = self.kernel[g_y[0] : g_y[1] + 1, g_x[0] : g_x[1] + 1]
  
      if self.use_kps_weights:
          kps_weights = np.multiply(kps_weights, self.kps_weights)
  
      # plot_heatmap(image, heatmap, kps, kps_weights)
  
      target["heatmap"] = torch.as_tensor(heatmap, dtype=torch.float32)
      target["kps_weights"] = torch.as_tensor(
          kps_weights, dtype=torch.float32
      )
  
      return image, target
  
imports: import math
  import random
  from typing import Tuple
  import cv2
  import numpy
  import torch
  from torchvision.transforms import functional
  import matplotlib.pyplot
label_desc: Use image node_id 2 for calling the KeypointToHeatMap obj's underlying member method code with example usage: obj.__call__(image, target) and returns: image,  target