code: def resize_boxes(boxes, original_size, new_size):
      # type: (Tensor, List[int], List[int]) -> Tensor
      """
      将boxes参数根据图像的缩放情况进行相应缩放
  
      Arguments:
          original_size: 图像缩放前的尺寸
          new_size: 图像缩放后的尺寸
      """
      ratios = [
          torch.tensor(s, dtype=torch.float32, device=boxes.device)
          / torch.tensor(
              s_orig, dtype=torch.float32, device=boxes.device
          )
          for s, s_orig in zip(new_size, original_size)
      ]
      ratios_height, ratios_width = ratios
      # Removes a tensor dimension, boxes [minibatch, 4]
      # Returns a tuple of all slices along a given dimension, already without it.
      xmin, ymin, xmax, ymax = boxes.unbind(1)
      xmin = xmin * ratios_width
      xmax = xmax * ratios_width
      ymin = ymin * ratios_height
      ymax = ymax * ratios_height
      return torch.stack((xmin, ymin, xmax, ymax), dim=1)
  
imports: import math
  from typing import List, Tuple, Dict, Optional
  import torch
  from torch import nn, Tensor
  import torchvision
  from .image_list import ImageList
label_desc: Use image node_id 3 for calling a global function with example usage: resize_boxes(boxes, original_size, new_size) and returns: torch