code: def _setup_scales(
      features: List[Tensor],
      image_shapes: List[Tuple[int, int]],
      canonical_scale: int,
      canonical_level: int,
  ) -> Tuple[List[float], LevelMapper]:
      if not image_shapes:
          raise ValueError("images list should not be empty")
      max_x = 0
      max_y = 0
      for shape in image_shapes:
          max_x = max(shape[0], max_x)
          max_y = max(shape[1], max_y)
      original_input_shape = (max_x, max_y)
  
      scales = [
          _infer_scale(feat, original_input_shape) for feat in features
      ]
      # get the levels in the feature map by leveraging the fact that the network always
      # downsamples by a factor of 2 at each level.
      lvl_min = -torch.log2(
          torch.tensor(scales[0], dtype=torch.float32)
      ).item()
      lvl_max = -torch.log2(
          torch.tensor(scales[-1], dtype=torch.float32)
      ).item()
  
      map_levels = initLevelMapper(
          int(lvl_min),
          int(lvl_max),
          canonical_scale=canonical_scale,
          canonical_level=canonical_level,
      )
      return scales, map_levels
  
imports: from typing import Dict, List, Optional, Tuple, Union
  import torch
  import torch.fx
  import torchvision
  from torch import nn, Tensor
  from torchvision.ops.boxes import box_area
  from ..utils import _log_api_usage_once
  from .roi_align import roi_align
label_desc: Use image node_id 5 for calling a global function with example usage: _setup_scales(features, image_shapes, canonical_scale, canonical_level) and returns: scales,  map_levels