code: def keypointrcnn_loss(
      keypoint_logits, proposals, gt_keypoints, keypoint_matched_idxs
  ):
      # type: (Tensor, List[Tensor], List[Tensor], List[Tensor]) -> Tensor
      N, K, H, W = keypoint_logits.shape
      if H != W:
          raise ValueError(
              f"keypoint_logits height and width (last two elements of shape) should be equal. Instead got H = {H} and W = {W}"
          )
      discretization_size = H
      heatmaps = []
      valid = []
      for proposals_per_image, gt_kp_in_image, midx in zip(
          proposals, gt_keypoints, keypoint_matched_idxs
      ):
          kp = gt_kp_in_image[midx]
          heatmaps_per_image, valid_per_image = keypoints_to_heatmap(
              kp, proposals_per_image, discretization_size
          )
          heatmaps.append(heatmaps_per_image.view(-1))
          valid.append(valid_per_image.view(-1))
  
      keypoint_targets = torch.cat(heatmaps, dim=0)
      valid = torch.cat(valid, dim=0).to(dtype=torch.uint8)
      valid = torch.where(valid)[0]
  
      # torch.mean (in binary_cross_entropy_with_logits) doesn't
      # accept empty tensors, so handle it sepaartely
      if keypoint_targets.numel() == 0 or len(valid) == 0:
          return keypoint_logits.sum() * 0
  
      keypoint_logits = keypoint_logits.view(N * K, H * W)
  
      keypoint_loss = F.cross_entropy(
          keypoint_logits[valid], keypoint_targets[valid]
      )
      return keypoint_loss
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn.functional
  import torchvision
  from torch import nn, Tensor
  from torchvision.ops import boxes, roi_align
  from .None import _utils
label_desc: Use image node_id 9 for calling a global function with example usage: keypointrcnn_loss(keypoint_logits, proposals, gt_keypoints, keypoint_matched_idxs) and returns: keypoint_loss, unknown