code: def keypoints_to_heatmap(keypoints, rois, heatmap_size):
      # type: (Tensor, Tensor, int) -> Tuple[Tensor, Tensor]
      offset_x = rois[:, 0]
      offset_y = rois[:, 1]
      scale_x = heatmap_size / (rois[:, 2] - rois[:, 0])
      scale_y = heatmap_size / (rois[:, 3] - rois[:, 1])
  
      offset_x = offset_x[:, None]
      offset_y = offset_y[:, None]
      scale_x = scale_x[:, None]
      scale_y = scale_y[:, None]
  
      x = keypoints[..., 0]
      y = keypoints[..., 1]
  
      x_boundary_inds = x == rois[:, 2][:, None]
      y_boundary_inds = y == rois[:, 3][:, None]
  
      x = (x - offset_x) * scale_x
      x = x.floor().long()
      y = (y - offset_y) * scale_y
      y = y.floor().long()
  
      x[x_boundary_inds] = heatmap_size - 1
      y[y_boundary_inds] = heatmap_size - 1
  
      valid_loc = (
          (x >= 0) & (y >= 0) & (x < heatmap_size) & (y < heatmap_size)
      )
      vis = keypoints[..., 2] > 0
      valid = (valid_loc & vis).long()
  
      lin_ind = y * heatmap_size + x
      heatmaps = lin_ind * valid
  
      return heatmaps, valid
  
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 5 for calling a global function with example usage: keypoints_to_heatmap(keypoints, rois, heatmap_size) and returns: heatmaps,  valid