code: def test_assign_targets_to_proposals(self):
      proposals = [torch.randint(-50, 50, (20, 4), dtype=torch.float32)]
      gt_boxes = [torch.zeros((0, 4), dtype=torch.float32)]
      gt_labels = [torch.tensor([[0]], dtype=torch.int64)]
  
      box_roi_pool = MultiScaleRoIAlign(
          featmap_names=["0", "1", "2", "3"],
          output_size=7,
          sampling_ratio=2,
      )
  
      resolution = box_roi_pool.output_size[0]
      representation_size = 1024
      box_head = TwoMLPHead(4 * resolution**2, representation_size)
  
      representation_size = 1024
      box_predictor = FastRCNNPredictor(representation_size, 2)
  
      roi_heads = RoIHeads(
          # Box
          box_roi_pool,
          box_head,
          box_predictor,
          0.5,
          0.5,
          512,
          0.25,
          None,
          0.05,
          0.5,
          100,
      )
  
      matched_idxs, labels = roi_heads.assign_targets_to_proposals(
          proposals, gt_boxes, gt_labels
      )
  
      assert matched_idxs[0].sum() == 0
      assert matched_idxs[0].shape == torch.Size(
          [proposals[0].shape[0]]
      )
      assert matched_idxs[0].dtype == torch.int64
  
      assert labels[0].sum() == 0
      assert labels[0].shape == torch.Size([proposals[0].shape[0]])
      assert labels[0].dtype == torch.int64
  
file_path: vision/test/test_models_detection_negative_samples.py
imports: import pytest
  import torch
  import torchvision.models
  from common_utils import assert_equal
  from torchvision.models.detection.faster_rcnn import FastRCNNPredictor, TwoMLPHead
  from torchvision.models.detection.roi_heads import RoIHeads
  from torchvision.models.detection.rpn import AnchorGenerator, RegionProposalNetwork, RPNHead
  from torchvision.ops import MultiScaleRoIAlign
label_desc: Use image node_id 3 for calling the TestModelsDetectionNegativeSamples obj's underlying member method code with example usage: obj.test_assign_targets_to_proposals() without return types