code: def bbox_mapping(
      bboxes: Tensor,
      img_shape: Tuple[int],
      scale_factor: Union[float, Tuple[float]],
      flip: bool,
      flip_direction: str = "horizontal",
  ) -> Tensor:
      """Map bboxes from the original image scale to testing scale."""
      new_bboxes = bboxes * bboxes.new_tensor(scale_factor)
      if flip:
          new_bboxes = bbox_flip(new_bboxes, img_shape, flip_direction)
      return new_bboxes
  
imports: from typing import List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  from torch import Tensor
  from mmdet.structures.bbox import BaseBoxes
label_desc: Use image node_id 3 for calling a global function with example usage: bbox_mapping(bboxes, img_shape, scale_factor, flip, flip_direction) and returns: new_bboxes