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 (int): The minimum scale. Defaults to 0.3.
          max_scale (int): 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)
  
imports: import argparse
  import os.path
  import sys
  from typing import Optional, Tuple
  import cv2
  import mmcv
  import numpy
  from mmengine.config import Config, DictAction
  from mmengine.dataset import Compose
  from mmengine.registry import init_default_scope
  from mmengine.utils import ProgressBar
  from mmengine.visualization import Visualizer
  from mmocr.registry import DATASETS, VISUALIZERS
label_desc: Use image node_id 2 for calling a global function with example usage: _get_adaptive_scale(img_shape, min_scale, max_scale) and returns: min