code: def get_adaptive_scale(
      img_shape: Tuple[int, int],
      min_scale: float = 0.3,
      max_scale: float = 3.0,
  ) -> float:
      """Get adaptive scale according to image shape.
  
      The target scale depends on the the short edge length of the image. If the
      short edge length equals 224, the output is 1.0. And output linear scales
      according the short edge length.
  
      You can also specify the minimum scale and the maximum scale to limit the
      linear scale.
  
      Args:
          img_shape (Tuple[int, int]): The shape of the canvas image.
          min_scale (float): The minimum scale. Defaults to 0.3.
          max_scale (float): The maximum scale. Defaults to 3.0.
  
      Returns:
          int: The adaptive scale.
      """
      short_edge_length = min(img_shape)
      scale = short_edge_length / 224.0
      return min(max(scale, min_scale), max_scale)
  
file_path: mmdetection/projects/XDecoder/xdecoder/inference/image_caption.py
imports: import copy
  import os.path
  from typing import Iterable, List, Optional, Tuple, Union
  import mmcv
  import mmengine
  import numpy
  import torch
  from mmengine.dataset import Compose
  from rich.progress import track
  from mmdet.apis.det_inferencer import DetInferencer, InputsType, PredType
  from mmdet.utils import ConfigType
label_desc: Use image node_id 1 for calling a global function with example usage: get_adaptive_scale(img_shape, min_scale, max_scale) and returns: min