def loss(self,
             feats: Tuple[Tensor],
             batch_data_samples: OptSampleList,
             train_cfg: ConfigType = {}) -> dict:
        """Calculate losses from a batch of inputs and data samples.

        Args:
            feats (Tuple[Tensor]): The multi-stage features
            batch_data_samples (List[:obj:`PoseDataSample`]): The batch
                data samples
            train_cfg (dict): The runtime config for training process.
                Defaults to {}

        Returns:
            dict: A dictionary of losses.
        """
        pred_heatmaps, pred_offside = self.forward(feats)
        gt_heatmaps = torch.stack(
            [d.gt_fields.heatmaps for d in batch_data_samples])
        keypoint_weights = torch.stack([
            d.gt_instance_labels.keypoint_weights for d in batch_data_samples
        ])
        gt_offside = torch.stack(
            [d.gt_fields.displacements for d in batch_data_samples])

        # calculate losses
        losses = dict()
        heatmap_loss = self.loss_module['heatmap'](pred_heatmaps, gt_heatmaps,
                                                   keypoint_weights)

        n, c, h, w = pred_offside.size()
        offside_loss_x = self.loss_module['offside'](pred_offside[:, :c // 2],
                                                     gt_offside[:, :c // 2],
                                                     gt_heatmaps)

        offside_loss_y = self.loss_module['offside'](pred_offside[:, c // 2:],
                                                     gt_offside[:, c // 2:],
                                                     gt_heatmaps)

        offside_loss = (offside_loss_x + offside_loss_y) / 2.

        losses.update({
            'loss/heatmap': heatmap_loss,
            'loss/offside': offside_loss,
        })
        # calculate accuracy
        if train_cfg.get('compute_acc', True):
            _, avg_acc, _ = pose_pck_accuracy(
                output=to_numpy(pred_heatmaps),
                target=to_numpy(gt_heatmaps),
                mask=to_numpy(keypoint_weights) > 0)

            acc_pose = torch.tensor(avg_acc, device=gt_heatmaps.device)
            losses.update(acc_pose=acc_pose)

        return losses
Calculate losses from a batch of inputs and data samples.

        Args:
            feats (Tuple[Tensor]): The multi-stage features
            batch_data_samples (List[:obj:`PoseDataSample`]): The batch
                data samples
            train_cfg (dict): The runtime config for training process.
                Defaults to {}

        Returns:
            dict: A dictionary of losses.
        
mmpose/projects/skps/models/skps_head.py