def encode(self,
               keypoints: np.ndarray,
               keypoints_visible: Optional[np.ndarray] = None) -> dict:
        """Encode keypoints into heatmaps. Note that the original keypoint
        coordinates should be in the input image space.

        Args:
            keypoints (np.ndarray): Keypoint coordinates in shape (N, K, D)
            keypoints_visible (np.ndarray): Keypoint visibilities in shape
                (N, K)

        Returns:
            dict:
            - heatmaps (np.ndarray): The generated heatmap in shape
                (K, H, W) where [W, H] is the `heatmap_size`
            - offset_maps (np.ndarray): The generated offset maps in x and y
                directions in shape (2*K, H, W) where [W, H] is the
                `offset_map_size`
            - keypoint_weights (np.ndarray): The target weights in shape
                (N, K)
        """

        assert keypoints.shape[0] == 1, (
            f'{self.__class__.__name__} only support single-instance '
            'keypoint encoding')

        if keypoints_visible is None:
            keypoints_visible = np.ones(keypoints.shape[:2], dtype=np.float32)

        heatmaps, keypoint_weights = generate_unbiased_gaussian_heatmaps(
            heatmap_size=self.heatmap_size,
            keypoints=keypoints / self.scale_factor,
            keypoints_visible=keypoints_visible,
            sigma=self.sigma)

        offset_maps = self.generate_offset_map(
            heatmap_size=self.heatmap_size,
            keypoints=keypoints / self.scale_factor,
        )

        encoded = dict(
            heatmaps=heatmaps,
            keypoint_weights=keypoint_weights[0],
            displacements=offset_maps)

        return encoded
Encode keypoints into heatmaps. Note that the original keypoint
        coordinates should be in the input image space.

        Args:
            keypoints (np.ndarray): Keypoint coordinates in shape (N, K, D)
            keypoints_visible (np.ndarray): Keypoint visibilities in shape
                (N, K)

        Returns:
            dict:
            - heatmaps (np.ndarray): The generated heatmap in shape
                (K, H, W) where [W, H] is the `heatmap_size`
            - offset_maps (np.ndarray): The generated offset maps in x and y
                directions in shape (2*K, H, W) where [W, H] is the
                `offset_map_size`
            - keypoint_weights (np.ndarray): The target weights in shape
                (N, K)
        
mmpose/projects/skps/custom_codecs/skps_heatmap.py