code: def assign_targets_to_proposals(self, proposals, gt_boxes, gt_labels):
      # type: (List[Tensor], List[Tensor], List[Tensor]) -> Tuple[List[Tensor], List[Tensor]]
      matched_idxs = []
      labels = []
      for (
          proposals_in_image,
          gt_boxes_in_image,
          gt_labels_in_image,
      ) in zip(proposals, gt_boxes, gt_labels):
          if gt_boxes_in_image.numel() == 0:
              # Background image
              device = proposals_in_image.device
              clamped_matched_idxs_in_image = torch.zeros(
                  (proposals_in_image.shape[0],),
                  dtype=torch.int64,
                  device=device,
              )
              labels_in_image = torch.zeros(
                  (proposals_in_image.shape[0],),
                  dtype=torch.int64,
                  device=device,
              )
          else:
              #  set to self.box_similarity when https://github.com/pytorch/pytorch/issues/27495 lands
              match_quality_matrix = box_ops.box_iou(
                  gt_boxes_in_image, proposals_in_image
              )
              matched_idxs_in_image = self.proposal_matcher(
                  match_quality_matrix
              )
  
              clamped_matched_idxs_in_image = (
                  matched_idxs_in_image.clamp(min=0)
              )
  
              labels_in_image = gt_labels_in_image[
                  clamped_matched_idxs_in_image
              ]
              labels_in_image = labels_in_image.to(dtype=torch.int64)
  
              # Label background (below the low threshold)
              bg_inds = (
                  matched_idxs_in_image
                  == self.proposal_matcher.BELOW_LOW_THRESHOLD
              )
              labels_in_image[bg_inds] = 0
  
              # Label ignore proposals (between low and high thresholds)
              ignore_inds = (
                  matched_idxs_in_image
                  == self.proposal_matcher.BETWEEN_THRESHOLDS
              )
              labels_in_image[
                  ignore_inds
              ] = -1  # -1 is ignored by sampler
  
          matched_idxs.append(clamped_matched_idxs_in_image)
          labels.append(labels_in_image)
      return matched_idxs, labels
  
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 4 for calling the RoIHeads obj's underlying member method code with example usage: obj.assign_targets_to_proposals(proposals, gt_boxes, gt_labels) and returns: matched_idxs,  labels